Jump to content

[SOLVED] Simple regex


deadonarrival

Recommended Posts

I just need the regex to find a whole word within a string.

 

Eg

$string = "then he said hello to me";
$word = "hello";

if(_regex here_) 
{
//$word is in $string
}
else
{
//$word is not in string
}

 

I'm completely clueless with regex. Is it just something like preg_match("^(.*)$word(.*)$",$string); ?

Link to comment
https://forums.phpfreaks.com/topic/118658-solved-simple-regex/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.