regex/matchtext question

Klaus Major klaus at
Thu Feb 5 05:50:15 EST 2009

Hi all,

I have a nice matchtext script that extract "placeholders" from a text.
Like everything between "<<" and ">>" or "::" or "{" and "}"

This is the function I use, it#s a little script of Ken Ray (thanks  
that I could understand, at least a bit to modify it:-)

## extract placeholder tText,tdelimiter,delimiter2
## tdelimiter = the delimiter of the returned list of placeholders
## derdelimiter2 = the actual "borders" of the placeholders to extract
function platzhalterextrahieren dertext,derdelimiter,derdelimiter2

   if derdelimiter = empty then
     put TAB into derdelimiter
   end if
   if derdelimiter2 = empty then
     put "::" into derdelimiter2
   end if

   switch derdelimiter2
   case "::"
     put "::" into derdelimiter3
   case "<<"
     put ">>" into derdelimiter3
   case "{"
     put "}" into derdelimiter3
   end switch

     get matchText(dertext,"(?s)" & derdelimiter2 & "(.*?)" &  
     if it = false then
       exit repeat
     end if
     put derdelimiter2 & wert & derdelimiter3 into neu
     put neu & derdelimiter after neueliste
     replace neu with empty in dertext
   end repeat

   delete char -1 of neueliste
   return neueliste
end platzhalterextrahieren

This results in a list like:



You get the picture.

Works fine so far, but now I also wanted to use "[" and "]" and even  
"[[" and "]]"
but I cannot get the script to work. I tried to escape these  
characters like:
case "["
     put "\[" into derdelimiter2
     put "\]" into derdelimiter3

I need to replace the german decimal delimiter COMMA with a dot before  
I can
finally MERGE the content of the text, and replace it with a COMMA  
after the MERGE.
Know what I mean?

But then I get stuck in an endless repeat loop?!

Is this possible at all with matchtext?
Any hints are highly appreciated!

Thanks a lot in advance!



Klaus Major
klaus at

More information about the Use-livecode mailing list