matchChunk to find fontNames

Claudi Cornaz claudi.c at fiberworld.nl
Wed Jun 22 18:29:54 EDT 2005


Hi all,

I am trying to implement a text menu and need to find all the fontNames
and text attributes in the selectedChunk first to update my menu and 
afterwards
to handle the choice.
As long as all the text has all the same attributes (bold / italic etc) 
it's no problem
but I need also to find all the attributes when it's mixed.

I have been trying to get the instances of  <font face=" xxxx xxx - 
xxx" [Size="yy"] [color="#ZZZZZZ"]>
to extract all the parts like, the fontname, the size and the color if 
applicable with matchChunk.

I start to understand regex a little bit, but I still did not got it to 
work just right.

Here is what I got sofar to get the whole font face tag:
   matchChunk(tText, "(<font face=\"[A-z\- ]+\">)", tStart, tEnd)

Some fontNames have spaces or - in theire name but if I add them to the 
regex like in the above example
the end goes on to far like: Stone Sans OS ITC TT-Bold" 
color="#FF0000">zeker</font> . . .   . . . etc

I tried to change the regex part with a $ at the end so it should stop 
at the ">" char.
   matchChunk(tText, "(<font face=\"[A-z\- ]+\">$)", tStart, tEnd)

Well, no dice, now it finds nothing no more so obviously I am doing 
something wrong.
How should this be done?

Sugestions for a better way to find all the style runs are of course 
very welcome as well,
since I just "thought" of this way to do it, in fact after quite some 
thought this came as "best" solution
to my mind,  but wether this is the best way to do it, well probably 
not.

Anyway  much thanks in advance and all help appreciated

best wishes Claudi


More information about the use-livecode mailing list