Hi Thierry,
As a regex forum expert I am hoping you might have a minute
to take a look at my post at viewtopic.php?f=9&t=36139
Interested in your thoughts on learning / getting better with Regex and Livecode.
~ Rodney
Hi Rodney,
Finally found some time to chime in with my little regex experience...
Ok, let start with the tool Stam suggests - RegExRX.
Here is a screenshot with your original regex
including the $ at the end of the regex:
First, we can see that this regex works here, but as you experimented not in LiveCode.
This is true with any other tools (apps or online-tools).
There are some context differences which can be very annoying if one don't know/understand them.
To name few:
- PCRE_lib versions
- language implementing PCRE (php, Xojo, python...)
- regex default options
That said, back to your regex which is constructed like: ( ^ .... $ )
In livecode by default, the carret points to the beginning of the input string, but not the beginning of a line
Same behavior with the $; end of string not end of line.
This is why it didn't work except if you change the mode: multi-lines -> (?m)
Now, rewriting your regex this way: (?m) ( ^ .... $ ), it should work.
Or you can simply ignore the carret and the $ and it should be fine too with the datas you provided earlier.
Investigating a bit further the regex, what about false positives?
Looking in the picture above the last lines which are not valid phone numbers but they match.
So, depending of what you need to achieve, this regex is good enough or bad.
Et voila mon ami, HTH.
Kind regards,
Thierry