Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: Tk text widget indices.

by meredith (Friar)
on Jul 16, 2003 at 13:41 UTC ( #274813=note: print w/replies, xml ) Need Help??

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??


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 -

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.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://274813]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2022-01-23 01:55 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (63 votes). Check out past polls.