정규식 - 특정 문자열 제외

개발툴 2014. 7. 3. 20:55

정규식에서 특정 단어를 제외하고 검색하고 싶으면


^((?!<문자열>).)*$


라인시작으로부터 ( ^ ) , <문자열>이 일치하지 않고 (?!) 어떤 문자들이 뒤에 위치할 수도 있은 뒤에 ( (.)* ) 라인 종료 ($)


역시 우리의 스택오버 플로우로부터. 


http://stackoverflow.com/questions/406230/regular-expression-to-match-string-not-containing-a-word



Note that the solution to does not start with “hede”:

^(?!hede).*$

is generally much more efficient than the solution to does not contain “hede”:

^((?!hede).)*$

The former checks for “hede” only at the input string’s first position, rather than at every position.

'개발툴' 카테고리의 다른 글

python 콘솔등에서 출력 텍스트 컬러  (0) 2014.07.25
Mac Os Terminal Color  (0) 2014.07.24
정규식 - 기본 구문  (0) 2014.07.03
mac os 업데이트 후 brew path 가 맞지 않는 경우  (0) 2014.07.01
SVN  (0) 2014.06.23