Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim and Regular Expression: what kind of regex does Vim use?

Tags:

regex

vim

testing

Since 6 months I'm using the excellent Vim text-editor. The most interesting thing is Vim's excellent regex support build-in.

I would like to understand regex better in order to ask less questions here :)

I tried Regex coach, Espresso and other regex-help applications but I found out that even if they are working in these applications it often doesn't work in VIM. What kind of regex does Vim use? Are there any help applications in which I can build regex commands for Vim?

like image 488
Reman Avatar asked Apr 24 '11 10:04

Reman


2 Answers

As far as I know vim uses it's own flavor. Here is what the manual says:

Vim's regexes are most similar to Perl's, in terms of what you can do. The difference between them is mostly just notation;

If you want a better (more serious) explanation, look up "Traditional NFA" in Mastering Regular Expressions.

like image 134
cnicutar Avatar answered Nov 15 '22 20:11

cnicutar


Vim has several regex modes, one of which is very magic that's very similar to traditional regex. Just put \v in the front and you won't have to escape as much.

like image 40
butterywombat Avatar answered Nov 15 '22 19:11

butterywombat