Ok, here again.
I’ll promise to study deeply the regular expression soon 😛
Language: PhP
Problem:
Match if some badword exist inside a string and do something.
The word must be not included inside a “greater word”. I mean if i’ll search for “rob” (sorry Rob, i’m not thinking you’re a badword), the word “problem have to pass without check.
I’d googled around but found nothing good for me. So, I thought something like this:
If i match the word with after and before any character of the following:
- .
- ,
- ;
- :
- !
- ?
- (
- )
- +
- –
- [whitespace]
I can simulate a check against single word inside a string.
Finally the Questions:
- There’s a better way to do it?
- If not, which will be the correct regexp to consider [all_that_char]word[all_that_char]?
Thanks in advance to anyone would help!
Maybe this is a very stupid question but today is one of that day when move our neurons causes an incredible headache 😐
Look up
\b(word boundary):(http://www.regular-expressions.info/reference.html)
So:
\brob\bmatchesrob, but notproblem.