1

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.

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
ZAIN Ali
  • 95
  • 9
  • 1
    See these pages for the syntax of lookarounds in vim https://stackoverflow.com/questions/21148467/is-there-a-way-to-do-negative-lookahead-in-vim-regex https://stackoverflow.com/questions/18391665/vim-positive-lookahead-regex – The fourth bird Feb 10 '21 at 07:51

1 Answers1

1

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)@!
Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563