How to find a "word" reliably with strmatch?

here’s a number of possible strings I’m dealing with:

“On Change”
“OffToOn OnToOff”
“OffToOn On”
“Change On Off”

I’d need to figure out which strings contain the word “On” (so the second string above would fail since On is only part of other words).

strmatch(“On”,$mystring) obviously would capture all of the above, which is not what I want.

If it can’t be done, maybe we should have the equivalent of a “word separator” symbol added to strmatch? (in perl it’s \b if I’m not mistaken, which matches spaces, beginning of strings, end of strings, etc.)

tx
d

the solution is to add a spaces to the start and end of the string being searched. Basically you would look in these strings:

" On Change "
" OffToOn OnToOff "
" OffToOn On "
" Change On Off "

and your searchstring would be “* On *”

so to put it all in one expression:

`strmatch("* On *", " "+$string+" ")`

cheers
markus

mmmm… I guess I could add those automatically to the cells, so I don’t have to rely on users/developers later on to remember to do that.

But it sure would be nice to be able to use a special character as word delimiter.

tx
d