nitely / nim-regex

Pure Nim regex engine. Guarantees linear time matching
https://nitely.github.io/nim-regex/
MIT License
227 stars 20 forks source link

Non-greedy ? operator broken in 0.14.0 #61

Closed genotrance closed 4 years ago

genotrance commented 4 years ago

Found in nimterop CI.

import regex

var a = "void __mingw_setusermatherr (int (__attribute__((__cdecl__)) *)(struct _exception *));"

echo a.replace(re"__attribute__[ ]*\(\(.*?\)\)([ ,;])", "$1")

# v0.13.1 => "void __mingw_setusermatherr (int ( *)(struct _exception *));"
# v0.14.0 => "void __mingw_setusermatherr (int (;"

Basically, .*? matches to the last )) near the end of the line instead of the first )).

nitely commented 4 years ago

This works in both versions: __attribute__[ ]*\(\(.*?\)\)(.*?[ ,;]). The previous version (v0.13.1) is the buggy one.

Let me know if this fixes it. Thanks for reporting this!

nitely commented 4 years ago

Wait, I think I'm wrong. That expression should match until the first )).

genotrance commented 4 years ago

Yes - 0.13.1 is what we want.