Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
regex weird behaviour
#1
Photo 
Hi,
I'm experimenting a quite weird behaviour of this very simple regex:
Macro Macro40
Code:
Copy      Help
out
;str r = "433\.[^4567]1"
str r = "433\.[012389]1"
str c = "433.21"
str t
ARRAY(str) ris
if(findrx(c r 0 2 t)>=0)
,out t
else
,out "no match"

it SHOULD give a match but it doesn't:
[Image: regex-No-Match.png]

But if I change the character class negating the opposite of the ones I want to match, it works:
Macro Macro40
Code:
Copy      Help
out
str r = "433\.[^4567]1"
;str r = "433\.[012389]1"
str c = "433.21"
str t
ARRAY(str) ris
if(findrx(c r 0 2 t)>=0)
,out t
else
,out "no match"

[Image: regex-Does-Match.png]

If I test the regex onĀ https://regex101.com (PCRE engine) it works, and so it does in RegexBuddy.
Negating the opposite could be a workaround, but is there a way to make character class working as expected?
Am I doing things wrong?

many thanks


Messages In This Thread
regex weird behaviour - by zandar - 02-06-2022, 09:32 AM
RE: regex weird behaviour - by Gintaras - 02-06-2022, 04:24 PM
RE: regex weird behaviour - by zandar - 02-06-2022, 05:58 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)