regex question

Mark Wieder mwieder at ahsoftware.net
Thu Dec 1 16:37:04 EST 2005


All-

Is there a way to tell matchChunk() not to be greedy?

I've got a regular expression stumper here. I'm using regex with the
matchChunk() function and I've BZed a problem with it. Now I'm looking
for a workaround that still manages to use matchChunk().

MatchChunk() is apparently implementing regex's "greedy" mode, so a
call to matchChunk() returns everything between the first <B> tag and
the *last* </B> tag. So...

put "<B>hello, bucko</B> this is a <B>test</B>"
matchChunk(tRawText, "(?s)<B>(.+)</B>", tPos, tEnd)

returns "hello, bucko</B> this is a <B>test"

What I'd like to return is just "hello, bucko". Is there some regex
incantation that will do this for me? I can't seem to come up with it.

-- 
-Mark Wieder
 mwieder at ahsoftware.net




More information about the use-livecode mailing list