MatchWithin

John Craig jc at spl21.net
Sun Nov 26 15:51:24 EST 2006


There are some extra parenthesis - a more concise version is;

FUNCTION MatchWithin pRawText, pStartText, pEndText
    if matchText(pRawText, "(?Uis)" & pStartText & "(.+)" & pEndText, 
tReturn) then return tReturn
END MatchWithin

JC

Mark Wieder wrote:
> 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
>
>   





More information about the use-livecode mailing list