Atomic Habits

Vim 정규식 본문

카테고리 없음

Vim 정규식

체계성 2022. 5. 19. 06:55

\(foo \)\@<=bar\( baz\)\@= matches the “bar” in foo bar baz. But the lookaround groups are still required, so it doesn't match at all for foo bar qux or foo bar or foo.
(foo )@<=bar( baz)@= in very magic mode.
\(mi \)\@<=casa matches “casa” if preceded by “mi ”. So it matches only the first “casa” in mi casa es su casa.
\(mi \)\@<!casa matches “casa” if not preceded by “mi ”. So it matches only the second “casa” in mi casa es su casa.
dad.\@= matches “dad” if followed by a period. So it matches only the second “dad” in My dad is bigger than your dad.
dad.\@! matches “dad” if not followed by a period. So it matches only the first “dad” in My dad is bigger than your dad.
Help

 

 
http://vimdoc.sourceforge.net/htmldoc/pattern.html#/\@=  < 아래 다양한 예시 !! >
https://vim.fandom.com/wiki/Regex_lookahead_and_lookbehind

 

Regex lookahead and lookbehind

If you want to search for a pattern only when it occurs next to another pattern, use the regex features “lookahead” and “lookbehind” (collectively “lookaround”). If you want to search for a pattern only when it doesn't occur next to another, us

vim.fandom.com

 

 

VIM 정규식
전방탐색/후방탐색
긍정형/부정형

(?=) : \(\)\@= : 긍전
(?<=) : \(\)\@<= : 긍후
(?!) : \(\)\@! : 부전
(?<!) : \(\)\@<! : 부후


3(?=천)
1000원, 3천원, 33원 >>> /3\(\)천\@= >>> 1000원, [3]천원, 33원

(?<=천)원
1000원, 3천원, 33원 >>> /\(\)천\@<=원 >>> 1000원, 3천[원], 33원

3(?!천)원
1000원, 3천원, 33원 >>> /3\(\)천\@!원 >>> 1000원, 3천원, 3[3원]

(?<!천)원
1000원, 3천원, 33원 >>> /\(\)천\@<!원 >>> 1000[원], 3천원, 33[원]

Comments