regex/matchtext question SOLVED

Klaus Major klaus at major-k.de
Thu Feb 5 06:12:55 EST 2009


Hi all,

after carefully reading my own post, I found the answer :-)
Now it works with "[" and "[["!

See below for the solution.

> 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  
> Ken!)
> 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
>    break
>  case "<<"
>    put ">>" into derdelimiter3
>    break
>  case "{"
>    put "}" into derdelimiter3
>    break
>  case "["
>    put "\[" into derdelimiter2
>    put "\]" into derdelimiter3
>    break
>  end switch
>
>  end switch
>
>  repeat
>    get matchText(dertext,"(?s)" & derdelimiter2 & "(.*?)" &  
> derdelimiter3,wert)
>    if it = false then
>      exit repeat
>    end if
>    put derdelimiter2 & wert & derdelimiter3 into neu
## !!!
replace "\" with "" in neu
>    put neu & derdelimiter after neueliste

## Otherwise there was no matching text to replace which ended in an  
eternal repeat loop!
>
>    replace neu with empty in dertext
>  end repeat
>
>  delete char -1 of neueliste
>  return neueliste
> end platzhalterextrahieren

Best

Klaus

--
Klaus Major
klaus at major-k.de
http://www.major-k.de




More information about the Use-livecode mailing list