Regex matches under RegexRx, but not under Xojo?

this is certainly for @Kem_Tekinay !

I have a regex that matches the pattern under regexrx, but match stays nil under xojo
any idea of what it can come from ?

I copied the sqlsource and rx.searchpattern from the xojo debugger into regexrx.

thanks.


Log the SearchPattern and compare the output to what’s in RegExRX. I’ll bet you’ll spot an unexpected difference. (Keep in mind that there could be invisible like EOL characters.)

there is an \n before FOREIGN in the searchpattern, but it is also in the pattern so it IS matched
is there a xojo option to match the newline ?

what do you mean exactly by “log the searchpattern” ? in xojo ? in regexrx ?

I meant something like using System.DebugLog, but since there are invisible characters are play here, try this:

var pattern as string = *your search pattern*

var c as new Clipboard
c.Text = pattern
c.Close

rx.SearchPattern = pattern
// Etc

Run that, then paste into a new RegExRX window against the same text. It should be easy to spot the differences at that point.

Also, unless you need that comma, I’d change the pattern to:

\bFOREIGN\b[^(]*\( ...
1 Like

so you think there may be some invisible characters in the pattern ?
I will look into that.

When my regexes work in a regex test app and not in Xojo it’s either the end-of-line characters or some options like greedy that are the culprits.

I played with the different options like greedy
 regexrx always get the match, and xojo don’t.
but it could be the newline that causes this.
anyway I think regexrx has been made with xojo, so the match results should be the same ?

the pattern doesn’t seems to have hidden characters in it.

if I remove the \n from the pattern, the regex now has a match in xojo 

anyway I don’t understand why the result is different between xojo and regexrx ?

If there is a hidden character then it’s in the text and not the regex. Try with (\r|\n) instead of \n.

it is really a 0x0D newline character in the text

seems there was a mix between 0x0a (endofline) and 0x0d

thanks Beatrix.

1 Like

FYI, \R matches any eol character.

2 Likes