기본 콘텐츠로 건너뛰기

정규표현식 예시

    목차

.NET(C#)

웹페이지 (URL)

@"^(http|https|ftp|)\://|[a-zA-Z0-9\-\.]+\.[a-zA-Z](:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&%\$#\=~])*[^\.\,\)\(\s]$";

https://regex101.com/r/krLmSN/1



숫자 검출

^(?<number>\d+)$

https://regex101.com/r/LDa0Ji/1



파일명에서 숫자로 된 파일명

^(?<imageFileName>(?<imageNumber>\d+)\.json)$

https://regex101.com/r/HlsvYw/1

응용

^(?<FullFileName>(?<imageNumber>\d+)(?:_[ho]\.png|\.json))$

https://regex101.com/r/Mc5BtU/1



기타 (Unity)


(편집기) "GetComponent"함수는 검색 단, "TryGetComponent" 제외


(?<!Try)GetComponent\s*<\w+>\s*\(

  • (?<!Try) : Try라는 단어가 앞에 오지 않도록 함 (부정 탐색)
  • GetComponent : 정확히 GetComponent 문자열을 찾음
  • \s*<\w+>\s* : 제네릭 타입 <T>을 포함하는 부분을 매칭
  • \( : 여는 소괄호를 포함하여 함수 호출을 정확히 찾음








댓글