MatchWithin
Mark Wieder
mwieder at ahsoftware.net
Sun Nov 26 13:55:20 EST 2006
All-
Yesterday I had a need for a utility function that returns the text
between two HTML tags, so I cobbled this together, but it will work
for any text, not just tags. If you have, for example,
pText = "<a href='x.html'>click here<h3>This is a title</h3></a>"
you can call
put MatchWithin(pTtext, "<h3>", "</h3>")
and get "This is a title"
Any comments? Can it be made easier? Faster? Is there a better way to
do this?
FUNCTION MatchWithin pRawText, pStartText, pEndText
local tReturn
IF matchText(pRawText, "((?Uis)" & pStartText & "(.+)" & pEndText& ")", tReturn) THEN
delete char -length(pEndText) to -1 of tReturn
delete char 1 to length(pStartText) of tReturn
END IF
return tReturn
END MatchWithin
--
-Mark Wieder
mwieder at ahsoftware.net
More information about the use-livecode
mailing list