Regex negative lookbehind makes a normal lookbehind or gives an error

I am trying to get a regex to capture some data with a negative lookbehind, so it won’t match if a certain string surpasses it. I know that there are two main formats, but they do not work. I do this in a search application and cannot use java to increase, so the solution should be pure with a regular expression .

This format gives me the error message "Regular expression syntax expression: invalid quantifier"

(?<!Product) Type : (.*?)<

This format acts like a normal lookbehind and is fixed only when Type precedes Product:

(?!=Product) Type : (.*?)<

What am I doing wrong?

+6
source share
1 answer
 (?<!Product)[ ]Type[ ]:[ ](.*?)< 

This should do what you want. You must bracket the spaces []

It will not match:

Product Type : xyz<

but it will match and capture xyz :

Other Type : xyz<

+3
source

Source: https://habr.com/ru/post/926966/


All Articles