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.
Help for those learning Tcl or writing their own scripts.
g33k
Voice
Posts: 1 Joined: Mon Apr 12, 2010 3:29 pm
Post
by g33k » Mon Apr 12, 2010 3:32 pm
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?
nml375
Revered One
Posts: 2860 Joined: Fri Aug 04, 2006 2:09 pm
Post
by nml375 » Mon Apr 12, 2010 3:43 pm
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