Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
regex doesn't work: my error or bug?
Hi Gintaras,
this regex (PCRE flavour) finds the substring between two single quotes:
Select All      Help

It works well when tested in RegexBuddy 4, 
[Image: htdvd4.png]
in and

[Image: 2uglztg.png] [Image: 9jls1h.png]

but if fails in QM:

Select All      Help
str userNamePattern username risultato
username="WHERE nomepass = 'testname'"
userNamePattern = "(?<=')(.*?)(?=')"
if(findrx(username userNamePattern 0 0 risultato 2)>=0)
    out risultato
    mes "match for ''(?<=')(.*?)(?=')'' not found" "Error"

[Image: j5i0wl.png]

is it my fault?

Again thank you for your exceptional support.
It seems it is a bug or feature in the (older) library PCRE version that QM uses. I tested with current PCRE version and it works well.
Workaround 1: use + instead of *
Workaround 2: don't use (?<=')

Also, in you code the submatch argument is 2. Must be 0 or 1.

Macro Macro2980
Select All      Help
str userNamePattern username risultato
username="= 'testname'"
userNamePattern = "'(.*?)'"
int i=findrx(username userNamePattern 0 0 risultato 1)
out i
out risultato
Ok, i got it.

Thanks again

Forum Jump:

Users browsing this thread: 1 Guest(s)