Why do you have to escape some metacharacters in their regex engine, but not others? For example:
/foo[1-9]*
works as expected, but the regular expression
foo[1-9]+
must be expressed as
/foo[1-9]\+
in vim. Anybody know?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is because vim (actually vi) created their own regex flavor long before perl did. Even POSIX BRE and ERE came after vimwikipedia. They are still maintaining their own flavor so it’s quite different.
To make the answer more resourceful here is a quote from
ed‘s wiki.These two paragraphs have a lot of information! I wish I could bold it all. Some highlights,
edin 1971.edwas actually a reimplentation ofqed.qedwhich is actuallyed.ed, in 1976 William Joy (known as Bill Joy) wroteexwikipediavias the visual mode for a line editor calledexwikipediagrepwas inspired by special uses ofqedand latered.sedwas implemented as many of the scripting features of qed that were not supported by ed on Unixsedinfluenced the design ofawk.So vi Regular Expression were in
edwhich was written in 1971. It’s long before any other regular expression flavor.