Why does Regex not work anymore in 2022r3?

I have an old regex that I haven’t changed in years. Why did it stop working in 2022r3?

dim RegexString as String = "(^|\r|\n)From (\?\?\?@\?\?\?|-|.*@|\rX-Mozilla-Status:|Mon|Tue|Wed|Thu|Fri|Sat|Sun|MAILER-DEMON|MAILER-DAEMON|\x0D\x0AReturn-path:\s)"
dim theRegex as new Regex
dim theRegexMatch as RegexMatch
theRegex.Options.greedy = false
theRegex.Options.DotMatchAll = true
theRegex.searchPattern = RegexString

dim result As String
  If theRegexMatch <> Nil Then
    result = theRegexMatch.SubExpressionString(0)
  End If
  theRegexMatch = theRegex.Search
Loop Until theRegexMatch Is Nil

Text for testing:

From notification@facebookmail.com Mon Dec 31 22:29:25 2018
Return-Path: notification@facebookmail.com

From notification@facebookmail.com Mon Dec 31 21:34:09 2018
Return-Path: notification@facebookmail.com

Regextester shows 2 results:

And what happens in Xojo?

Sorry, I forgot: there are no search results at all.

I’m not at my desk to test it by myself. Can you test it with theRegex.Options.StringEndIsLineEnd = False please?

The following was made using RegExRX and brings 2 results:

Dim result As String
Dim rx As New RegEx
rx.SearchPattern = _
"(^|\r|\n)From (\?\?\?@\?\?\?|-|.*@|\rX-Mozilla-Status:|Mon|Tue|Wed|Thu|Fri|Sat|Sun|MAILER-DEMON|MAILER-DAEMON|\x" + _

Dim rxOptions As RegExOptions = rx.Options
rxOptions.Greedy = True
rxOptions.MatchEmpty = True
rxOptions.StringEndIsLineEnd = False
rxOptions.LineEndType = 0

Dim match As RegExMatch = rx.Search( RegexString )
While match IsA RegExMatch
  result = match.SubExpressionString(0)
  match = rx.Search // Fetch the next match
1 Like

My code was wrong. I forgot to set the match:

dim theRegexMatch as RegexMatch = theRegex.Search(mbox)

So my problem must be elsewhere. The regex is the central part of splitting large mbox files. Which did work for 2022r2.

1 Like

I’ll be watching your results carefully, I use LOTS of regex and any issue will cause me a world of hurt. Please update the thread on any Regex issue in 2022R3. Thanks.

I think I found the problem. Me being stupid as usual.

1 Like

Wrong. Probably a less than optimal day :wink:

Yeah, exactly.