Search code examples
javascriptc++regexnegative-lookbehind

What is an alternative method for negative look-behind using ECMAScript in C++?


I have the following text:

CCMRC Version: 00500000

RC Version: 01730000

I want to just get the number for RC Version, not CCMRC. So I want to get 01730000 not 00500000.

I have this regex pattern that should work:

(?<!CCM)RC Version: ([0-9]+)

But negative lookbehind I believe is not supported in C++. So does anyone know of another way this can be achieved? Thank you.


Solution

  • If the pattern you are looking for is at the beginning of a line, as appears to be the case, you can use:

    ^RC Version: ([0-9]+)
    

    which forces the match to only succeed at the beginning of a line.