Monday, November 15, 2010

Vim regexp example

I have a file : 
alert
  alert
  //alert

So, line 1 has "alert" without any white spaces.
line 2 has white spaces followed by "alert"
line 3 has white spaces,"//" followed by "alert"

I want to find "alert" which is not commented, i.e. not following "//"

Here is the regexp : 

/\(^\|[^\/\/]\)alert  

which is basically : 
(beginning of line OR absense of "//") followed by "alert"

No comments:

Blog Archive