Posted to tcl by kbk at Sat Jan 21 17:27:32 GMT 2012view raw

  1. % regexp -expanded {
  2. (?:^|[ ]) # this matches either the start of the string, or else
  3. # a single space character
  4. test # this matches the desired word, 'test'
  5. (?:$|[ ]) # this matches either the end of string, or else a
  6. # single space character
  7. } test
  8. 1
  9. % regexp -expanded {
  10. (?:^|[ ]) # this matches either the start of the string, or else
  11. # a single space character
  12. test # this matches the desired word, 'test'
  13. (?:$|[ ]) # this matches either the end of string, or else a
  14. # single space character
  15. } {this is a test case}
  16. 1
  17. % regexp -expanded {
  18. (?:^|[ ]) # this matches either the start of the string, or else
  19. # a single space character
  20. test # this matches the desired word, 'test'
  21. (?:$|[ ]) # this matches either the end of string, or else a
  22. # single space character
  23. } {I protest!}
  24. 0
  25.