How can I match a keyword that is completely on its own?
For instance I only want to match hello
in a string like these,
/say/hello/world/
/say/hello/
but not in these,
/say/helloworld/
/say/hello-world/
/say/hello+world/
/say_hello_world/
So far with this pattern,
var_dump(preg_match('~.*?(?=hello)~i', $string)); // int 1
It matches all of them!
I only want /something/hello/world/
to be int 1
- is it possible?