Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

regex containing all specific character combination in vim

Tags:

regex

vim

With the help of this post, I am able to search for the words containing combinations of all vowels letter.
regex:

(?=\w*a)(?=\w*e)(?=\w*i)(?=\w*o)(?=\w*u)\w+

matches example:

abstemious
education
reputation
facetious

I then change the following into vim expression as
regex:

\(\ze\w\{-}a\)\(\ze\w\{-}e\)\(\ze\w\{-}i\)\(\ze\w\{-}o\)\(\ze\w\{-}u\)\w\+

changes are

( to \(
?= to \ze
* to \{-}
+ to \+

But now it only matches serial occurrences like

abstemious 
facetious

not education,reputation

where do I missed?

like image 612
vusan Avatar asked Mar 11 '23 06:03

vusan


1 Answers

This vim-regex should help you:

\v(\w{-}a)@=(\w{-}e)@=(\w{-}i)@=(\w{-}o)@=(\w{-}u)@=\w+
  • The leading \v means match in very-magic mode, :h magic for details
  • look ahead in vim regex is (...)\@=, :h \@= for details
like image 56
Kent Avatar answered Mar 16 '23 21:03

Kent