RegexMBS and me don’t see eye to eye. Again I wanted to speed up a Xojo regex by using RegexMBS. But RegexMBS doesn’t find anything. The commented out Xojo regex works fine:
[code]dim theFolderitem as FolderItem = SpecialFolder.Desktop.Child(“test.emlx”)
if theFolderitem = Nil or not theFolderitem.Exists then Return
dim theBinStream as BinaryStream = BinaryStream.Open(theFolderitem)
dim MessageText as String = theBinStream.Read(10 * 1024)
'dim theRegex as new RegEx
'theRegex.searchPattern = “(
|\r)Message-ID: ?(.*)(
|\r)”
'dim theRegexMatch as RegExMatch = theRegex.search(MessageText)
'if theRegexMatch = nil then
'return “”
'elseif theRegExMatch.SubExpressionCount >= 2 then
'return theRegexMatch.subExpressionString(2).Trim
'end if
MessageText = MessageText.DefineEncoding(Encodings.UTF8)
dim theRegexMBS as new RegExMBS
theRegexMBS.CompileOptionUngreedy = true
theRegexMBS.CompileOptionMultiline = True
theRegexMBS.CompileOptionNewLineAny = True
dim result as string
if theRegexMBS.Compile("(
|\r)Message-ID: ?(.*)(
|\r)") then
if theRegexMBS.Match(MessageText) then
result = theRegexMBS.Substring(2)
else
result = “nichts gefunden”
end if
end if[/code]
I uploaded the test file to https://www.mothsoftware.com/downloads/test.zip. It can only be a newline problem. But the explanations for CompileOptionNewLineAny are confusing.
By the way, looking at the variables in the debugger makes the debugger crash. I had a Messagebox theRegexMBS.Substring(2) for testing. That also makes the debugger crash. Latest MBS, Xojo 2019r2.1. High Sierra.