Xojo regex vs regexrx

Hi guys,

I have a regex expression I tested fine in regexrx,
and when I copy-paste the code into xojo the match variable is nil after the search.

I checked encodings, endofline, they are all fine (i.e. defined UTF8 and unix)
what can be wrong ?

I made lots of this kind of work and they worked fine, but this one does not want to !

thanks.

dim rx as new RegEx
rx.SearchPattern = "(?mi-Us)Du (\d{4}) au (\d{4})|^(\d+);([\w|\s|-]+);|^-> (\d{4});|(\d+,\d{2})|(\[FIN\])"

dim rxOptions as RegExOptions = rx.Options
rxOptions.LineEndType = 3

dim match as RegExMatch = rx.Search( sourceText )
while match isa RegExMatch
//
// Do something
//

match = rx.Search // Fetch the next match
wend

My best guess is that sourcetext isnā€™t what you think it is.

1 Like

I stopped the program at the dim match ā€¦ line
copied the source text
pasted it in regexrx
it works in regexrx, and match gets nil in xojo ā€¦

and the best part of itā€¦
it is a file that gets imported in a database every month.
last month it worked fine
this month it doesnā€™t, and I havenā€™t touched anything in this part of the appā€¦
but the actual file in regexrx is regexed fine !

by the way @Kem_Tekinay do you use mbs regex or xojo regex in regexrx ?

I used MBS.

Is it a file you can send to me privately?

I might be misreading it on my phone, but this pattern seems wrong. The ^ in the middle two patterns of the alternator would prevent those from ever matching.

(Also allow that I just woke up.)

take the time to wake up. will go back later. happy breakfast !

Does the ^ denote beginning of the line? You might want to use it as ^(regex)

Jean, would be great if you just say what you intend to match, and some mock up text lines, instead showing the pattern you got. Would also be great to show one line that currently is unexpectedly failing to match. Who knows if people could come up with another pattern that fits better for your need, if not, it will help to fix the current one.

yes ^ is for the beginning of line here

what bothers me is what can differ between a good match in regexrx and nothing in xojo !
here Iā€™m matching 5 different patterns and none is detected ?

You make it REALLY hard for anyone to help you. WHICH 5 patterns donā€™t match WHAT???

And have some text that people can copy/paste - or do you expect everyone to type in from the screenshot???

I shake my head at how inconsiderate people are when asking for help.

Markus, you are overreacting. Have a bit more patience. He is not a dumb guy. He certainly will provide something more ā€œworkableā€ for those wanting to help without so much ā€œemphasisā€.

2 Likes

the pattern you can copy it in my first post
for the file, sorry Iā€™m not allowed to upload it, I have to change the values inside before.

I donā€™t need to get another pattern,
I just wanted to know if you guys already had something like ok in regexrx and not in xojo regex.
I have to match whatā€™s is hilited in blue and pink in regexrx. the pattern is ok in regexrx

If your question is ā€œcan it be achieved?ā€, You got one, so yes.

If you ask me if I already saw something like that before, I must say, yes, I have seen different behaviors between 2 regex engines before.

I would understand some difference in the exact matches both engines provides
but not something like OK and NONE !

As you couldnā€™t provide any sample of the problem to help people to try to help you, you probably must figure out whatā€™s going on by yourself, sorry.

Check the encoding of the string in Xojo. Pasting into regexrx probably sets it to UTF8.