regex/matchtext question
Klaus Major
klaus at major-k.de
Thu Feb 5 08:21:06 EST 2009
Hi Jim,
looks like you missed my second post, I already found the solution to
my problem.
> Difficulty one is that '[' is a special character in regular
> expressions and
> escaping can make using them even more confusing. This is also true
> of the
> filter command.
Anyway, thanks for you post, will take a deeper look in a quiet
moment ;-)
> --this function seems to work
> --the catch is that the "[" and "]" are special chars
> --recall the merge("") function
>
> function getList dertext, derdelimiter, derdelimiter2
> put "<<,>>,{,},[,],{{,}},[[,]]" into oppositeDelm
> if not(derdelimiter is among the items of oppositeDelm)
> then put "::" into derdelimiter
> if not(derdelimiter2 is among the items of oppositeDelm)
> then put "::" into derdelimiter2
> replace cr with numtochar(3) in dertext --all on one line now
>
> if ( derdelimiter <> derdelimiter2 ) is true then
> replace derdelimiter with (cr & derdelimiter) in dertext
> replace derdelimiter2 with ( derdelimiter2 & cr ) in dertext
> if "]" is in dertext then -- we are using brackets
> replace ( derdelimiter2 & cr ) with ("^^" & cr) in dertext
> filter dertext with ( "*^^" )
> replace "^^" with ( derdelimiter2 ) in dertext --we are done
> else
> filter dertext with ( "*" & derdelimiter 2 ) --we are done
> end if
> else --using "::" symetrical double-delimiters
> replace ":" with (":" & cr & ":") in dertext
> replace "::" with empty in dertext
> filter dertext with (":*:")
> replace ":" with "::" in dertext --we are done
> end if
> return dertext
> end getList
>
> Hope this helps.
>
> Jim Ault
> Las Vegas
Best
Klaus
--
Klaus Major
klaus at major-k.de
http://www.major-k.de
More information about the use-livecode
mailing list