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.