[NJG] January 15, 2005 Recently I posted the page [A regexp twist]. Not having any feedback I have no idea how much attention it has received. It has, however, suddenly occured to me that neither the title nor the style of the prose were very advertising of its essence. So here is a more direct try. [A regexp twist] provides an extensiont to the functionality of the '''regexp''' command in the form of '''regexp -inline''' ''?other options?'' '''''pattern string script''''' where ''script'' would be executed each time a pattern match occured. (Note that in current Tcl this is illegal so it represents a compatible extension.) The result of the actual match is available to ''script'' in the global match variables ''mVar0'', ''mVar1'', .... ''mVar9''. For Windows users the '''''downloadable zip file''''' contains the source and the extension dll. Those on Linux may either replace the ''.dll'' specific part of the source with whatever is needed for compiling it into an ''.so'' module or replace the function ''Tcl_RegexpObjCmd'' in file ''tclCmdMZ.c'' of their Tcl source distribution with the one in the provided source and recompile Tcl. Lacking time I cannot help those who need a Linux binary. Please note: I have no idea which is the oldest Tcl version number for which this extension works. For Tcl 8.4.x it surely does. ---- [MG] takes a quick shot at this in pure-Tcl on 8.4.9 ... proc regexpScriptPre8.5 {args} { if { [llength $args] < 3 } { error "wrong # args" } set rArgs [lrange $args 0 end-3] set cmd [lindex $args end] eval "foreach x \[regexp -inline $rArgs \[lindex \$args end-2\] \[lindex \$args end-1\]\] \{ \ uplevel 1 \[list [list $cmd]\] \[list \$x\] \ \}" } Or, in 8.5 simplified with {expand} (though untested as I don't have 8.5) proc regexpScript8.5 {args} { if { [llength $args] < 3 } { error "wrong # args" } set rArgs [lrange $args 0 end-3] set cmd [lindex $args end] foreach x [regexp -inline {expand}$rArgs [lindex $args end-2] [lindex $args end-1]] { uplevel 1 [list $cmd] [list $x] } }