Posted to tcl by mjanssen at Wed Jan 25 20:31:39 GMT 2017view raw
- proc matchAll { string expressions } {
- foreach ex $expressions {
- if {![regexp -nocase $ex $string -> match]} {
- return false
- } else {
- puts "Matched: $match | Regexp: $ex"
- }
- }
- return true
- }
- 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"
- matchAll $test(1) [list (first)]
- matchAll $test(2) [list (second) (other)]
- matchAll $test(3) [list (final) (works) (last)]