Quote Originally Posted by jpn
One approach could be to use

int QString::indexOf ( const QRegExp & rx, int from = 0 ) const

and define the regexp to begin and end with a whitespace (\s).
To my mind you should use "\\b" instead of "\\s".
\b
A word boundary. For example the regexp \bOK\b means match immediately after a word boundary (e.g. start of string or whitespace) the letter 'O' then the letter 'K' immediately before another word boundary (e.g. end of string or whitespace). But note that the assertion does not actually match any whitespace so if we write (\bOK\b) and we have a match it will only contain 'OK' even if the string is "It's OK now".