Posted to tcl by mjanssen at Wed Jan 25 10:52:20 GMT 2017view pretty

proc firstMatch { string expressions } {
 foreach ex $expressions {
    if {[regexp -nocase $ex $string -> match]} {
	puts "Matched: $match | Regexp: $ex"
	return
    }
 }
}

set test(1) "this is first"
set test(2) "this is the second test and i match some other words in here"
set test(3) "this is the final test just hope that its works as it is the last test"

firstMatch $test(1) [list (first)]
firstMatch $test(2) [list (second) (other)]
firstMatch $test(3) [list (final) (works) (last)]