javascript 정규식(regexp, regular expression) "?!" 관련(Look ahead behind Positive Negative)
experience runtime에 변경되는 특정 문자열이 포함되지 않는 정규식 작성하기 위해 찾아보니, javascript 정규식중에 ?! quantifier가 있는 것 확인. 그런데, 문제는 ?!를 쓰는 경우, 특정 단어가 검색하려는 단어 뒤에 오지않게는 동작을 잘 하는데, 특정 단어가 검색하려는 단어 앞에 오지않게는 동작은 하지 않는다는 점... ex> /a(?!b)/ 정규식으로 "ac"를 test하면 a가 잘 찾아짐(true).. "ab"인 경우는 못찾음(false).. but, /(?!a)b/ 정규식으로 "ab"를 test하면 못찾아야 할 것 같지만, 잘찾음(true).. 확인해보니, ?!는 Look Ahead negative로 뒤 따르는 부분 기준인 듯... javascript에서는 Look Ahead positive(?=)과 Look Ahead negative만 지원 하는 듯... 관련 참고 내용(아래는 java기준) --------------------------------------------------------- given the string foobarbarfoo bar(?=bar) finds the first bar (Find "bar" which has "bar" after it) . bar(?!bar) finds the second bar (Fin "bar" which does not have a "bar" after it). (?<=foo)bar finds the first bar (Find "bar" which has "foo" before it). (?<!foo)bar finds the second bar (Fin "bar" which does not have "foo" before ...