http://qs321.pair.com?node_id=274813


in reply to Tk text widget indices.

Hrm, why arent you using regexes? I'm no master, but I think this will help:
m|\*\*(\w+)\b|g If you have all the text in a scalar, you can do this:
while($text =~ m|\*\*(\w+)\b|g) { print "Found: " , $1 , "\n"; }
Is this what you want? Or was there some reason you're using TK's functions??

HTH

Update: explanation of regex
m| \* #literal asterisk \* #ditto ( #start capture \w+ #one or more word characters aka [A-Za-z0-9_] ) #end capture \b #word boundary |gx #/x allows whitespace, /g makes it global (restart from last m +atch position in this case)
In case you're not familar with regexes, run this: perldoc perlretut :)

mhoward - at - hattmoward.org

Replies are listed 'Best First'.
Re: Re: Tk text widget indices.
by perl_seeker (Scribe) on Jul 18, 2003 at 12:01 UTC
    Hi ,
    Thanks a lot for the reply.Is it possible to do
    regex matches in a Tk text widget? I need not only
    to search for the **'s, I need to extract
    the word next to the 2nd *, change it's font color
    and then delete the **'s.The user needs to see the text
    in a window, and the font color change for certain words
    on a button click.
    I need to mark certain word with
    the color change instead of the **'s I previously used.
    Thanx