|
RegExMatch Class
Has Constructor: NO, Can Create Instance: YES Can Subclass: YES
User the RegEx object to perform search and replacements on strings using Regular Expressions. To create a new RegEx object declare a variable of type color and then create a new instance with the NEW statement.
See Also: RegEx
replace
Syntax: regex.replace([replacePattern] as string) as string
Replaces the expression matched using the replacement parttern passed. If you do not specify one the replacement pattern of the RegEx object will be used. Returns the resulting string.
subExpressionString
Syntax: regex.subExpressionString(expressionNum as integer) as string
Returns the subexpression as string.
subExpressionStart
Syntax: regex.subExpressionStart(expressionNum as integer) as integer
Returns the starting byte position of the expression as integer.
Count
Data Type: Integer
The number of subexpressions in the match.
sub main()
dim s as string, m as string
dim r as regEx,rm as regExMatch
msgbox("RegEx Class Test")
//setup the source string
s = "<html><head><title>Hello</title></head><body><b>My bold 1</b>"
s = s & "<br><b>My bold 2</b><u>some underline</u>"
s = s & "<b>Hello bold 3</b></body></html>"
r = new regEx
//find bold tags
r.searchpattern = "<b>.+?</b>"
r.greedy = false
rm = r.search(s)
dim i as integer,c as integer
if rm.nil = true then
msgbox("Text not found")
quit
end if
while rm.nil = false m = rm.SubExpressionString(0)
msgbox("Matched:\n" & m)
i = strlib.len(m) + rm.subExpressionStart(0)
rm = r.search(s,i)
wend
end sub
|