This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

working with multiple RegExp Matches

Help for those learning Tcl or writing their own scripts.
Post Reply
g
g33k
Voice
Posts: 1
Joined: Mon Apr 12, 2010 3:29 pm

working with multiple RegExp Matches

Post by g33k »

hi,

im writing a small website parsing tcl script. my question is how i can handle with multiple regexp matches? how can i work with every single match or how to put these in a variable?
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

I'd use something along these lines:

Code: Select all

set matches [regexp -inline -all -- {some pattern} data]
foreach {match submatch1 submatch2 ...} $matches {
 #do something useful for each match here...
}
Just make sure the variable-list in foreach matches the matchVar+subMatchVar set you'd normally use (when not using -inline).
NML_375
Post Reply