MatchWithin

John Craig jc at spl21.net
Sun Nov 26 14:57:12 CST 2006


Oh - I forgot to say - very useful!

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