@Kem Tekinay recently mentioned that RegexMBS is much faster than Xojo’s Regex. I started to test on a very simple piece of code.
The original code where I need to check if some text of 100 chars is Base64Encoded:
[code]Private Function IsReallyBase64Encoded(theLeft as String) as Boolean
theLeft = ReplaceLineEndingsMBS(theLeft, “”, True)
dim theStart as integer
dim theRegex as new Regex
theRegex.options.greedy = false
theRegex.searchPattern = “\s”
dim theRegexMatch as RegExMatch = theRegex.search(theLeft)
if theRegexMatch = nil then Return true
End Function[/code]
New code with RegexMBS:
[code]theLeft = ReplaceLineEndingsMBS(theLeft, “”, True)
dim theRegexMBS as new RegExMBS
theRegexMBS.CompileOptionCaseLess = True
theRegexMBS.CompileOptionUngreedy = true
dim MBSResult as Boolean
if theRegexMBS.Compile("\s") then
MBSResult = not theRegexMBS.Match(theLeft)
end if
Return MBSResult[/code]
I archived a couple of thousand emails. To my surprise that little change of code made the archival 10 seconds slower with MBS.
So when is MBS faster? For larger strings only? Why is MBS slower here?