Regex syntax error

Issue #826 resolved
Former user created an issue

Hi, monit 5.25.1 give me an error with this regular expression:

if content = (?<=dup=)([1-9]{3,}) then restart

I search for: co located POCs unavailablee=00:00:12.67 bitrate=N/A dup=123 drop=80 speed=0.899x

https://regex101.com/r/0M6qEF/2

The error is:

"syntax error '[1-9]'"

What is missing?

Comments (2)

  1. Henning Bopp

    Two problems here:

    1. You need to wrap in quotes (spoiler: won't work either): if content = "(?<=dup=)([1-9]{3,})" then restart
    2. You need to obey the regex(7) rules as stated in the documentation. So no positive lookbehind.

    So a finally working version would be:

    if content = "dup=[1-9]{3,}" then restart
    

    I removed the capturing group since there is no place to use it... Keep in mind that you are not matching a 0 here. Comparing with your regex101-link, it might be more like (this is only matching numbers >= 100)

    if content = "dup=[1-9][0-9]{2,}" then restart
    
  2. Log in to comment