ZAIN Ali
ZAIN Ali

Reputation: 105

Find exact number pattern regex not working in Linux vi editor

I have a regex that finds the consecutive 15 numbers. It works fine in the notepad but when I try to run it on vi editor in Linux, it shows no pattern found. Even though there are numbers of the same length. Here is the regex I am using.

Regex: (?<!\d)\d{15}(?!\d) Any help will be appreciated.

Upvotes: 1

Views: 147

Answers (1)

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 627082

Note that you need to do several things:

  • Add \v at the start to enable very magic mode to avoid over-escaping
  • Convert a (?<!\d) negative lookbehind to (\d)@<!
  • Convert a (?!\d) negative lookahead to (\d)@!
\v(\d)@<!\d{15}(\d)@!

Upvotes: 1

Related Questions