vusan
vusan

Reputation: 5331

regex containing all specific character combination in 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?

Upvotes: 4

Views: 107

Answers (1)

Kent
Kent

Reputation: 195039

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

Upvotes: 7

Related Questions