I'm trying to use the MBS Regex plugin but I'm finding it very complex (compared to Xojo's native but I think inferior implementation).
If I have a string like this:
"I am Garry Pettet. Not just Garry."
and a regular expression like this (to just match my first name exactly):
dim pattern = "Garry"
How can I get the start and end positions of the two "Garry" substrings? They should be [5, 10] and [28, 33]. I've only been able to manage to get the start and end offset of the first matching "Garry" with this code:
const PATTERN = "Garry const TEST = "I am Garry Pettet. Not just Garry." dim r as new RegExMBS if not r.Compile(PATTERN) then MsgBox("Failed") dim offsetCount as Integer = r.Execute(TEST) ' <--- This returns 1 dim offsets() as Integer for i as Integer = 0 to offsetCount ' offsets.Append(r.OffsetCharacters(i)) next i
Trouble is the
offsets array only contains [5, 10]. I'm not sure where I'm going wrong. Can anybody help?