Posted to tcl by mjanssen at Wed Jan 25 20:31:39 GMT 2017view raw

  1. proc matchAll { string expressions } {
  2. foreach ex $expressions {
  3. if {![regexp -nocase $ex $string -> match]} {
  4. return false
  5. } else {
  6. puts "Matched: $match | Regexp: $ex"
  7. }
  8. }
  9. return true
  10. }
  11.  
  12. set test(1) "this is first"
  13. set test(2) "this is the second test and i match some other words in here"
  14. set test(3) "this is the final test just hope that its works as it is the last test"
  15.  
  16. matchAll $test(1) [list (first)]
  17. matchAll $test(2) [list (second) (other)]
  18. matchAll $test(3) [list (final) (works) (last)]