Help using regexp in a TCL script ??

In a tcl script I need to find a way of reading a file, and looking for a phrase ("set myvariable") and putting the word following that into a variable.
I've used a file open, and a while loop with gets to read each line from the file into a variable, and using regexp searched for the item. I'm struggling how to specify and isolate the word following the match and then to put it into a variable.

set fd [open $target_name.tcl r]
while {[gets $fd lib_str] >= 0} {
  if {[regexp -nocase {\mset\W\mmyvariable\W} $lib_str match]} { 
  puts stdout $match
  }
}

This works in that it finds and prints set myvariable. :wall:?

Try this:

set fd [open $target_name.tcl r]
while {[gets $fd lib_str] >= 0} {
  if {[regexp -nocase {\mset\s+(myvariable)\s+(.+)$} $lib_str match var value]} { 
    puts stdout $match
    puts stdout $var
    puts stdout $value
  }
}