Returns the location of the last pattern match found.
| Category: | Regular Expression |
| Returned data type: | Integer |
// Define some string variables
string MyString
string MySubString
integer StartLocation
// Set one to some sample input
MyString = "00AA111BBB2222CCCC"
// Will hold the starting location of matched patterns
StartLocation = 0
//You must define a regex object
regex r
// Then compile your regular expression
// This one will match any single uppercase letter
r.compile("[A-Z]+")
// Find the first pattern match
if r.findfirst(MyString)
begin
// Pull the pattern from MyString and place it into MySubString
MySubString = mid(MyString, r.matchstart(),r.matchlength())
// Use pushrow to create new rows - this is purely for the sake of
// clarity in the example
pushrow()
// Create a while loop that continues to look for matches
while r.findnext(MyString)
begin
// Pull the pattern from MyString and place it into MySubString
again
MySubString = mid( MyString, r.matchstart(),r.matchlength())
// Set StartLocation to the starting point of each pattern found
StartLocation = r.matchstart()
// Just for display again
pushrow()
end
end
// Terminate the expression node processing
seteof(true)
// Prevent the last pushrow() from showing up twice
return false