Friday, 15 February 2013

Regex negation in vim -



Regex negation in vim -

in vim utilize regex highlight each line ends letter, preceeded neither // nor :. tried following

syn match systemverilognosemi "\(.*\(//\|:\).*\)\@!\&.*[a-za-z0-9_]$" oneline

this worked on comments, did not work on lines containing colon. thought why?

because regex vim can take point starting match regular expression. chooses point first concat matches (i.e. not have // or :). these things done using either

\v^%(%(\/\/|\:)@!.)*\w$

(removed first concat , branch itself, changed .* %(%(\/\/|\:)@!.)*; replaced collection equivalent \w; added anchor pointing start of line): if need match whole line. or negative look-behind if need match lastly character. can add together anchor first concat of variant (you should remove trailing .* first concat useless, , branch symbol same reason).

note: have no thought why regex worked comments. not work comments way need in cases checked.

regex vim negative-lookahead

No comments:

Post a Comment