$a = \'how are you\';
if (strpos($a,\'are\') !== false) {
echo \'true\';
}
In PHP, we can use the code above to check if a string contain speci
An easy way to do it to use Regex match() method :-
For Example
var str ="Hi, Its stacks over flow and stackoverflow Rocks."
// It will check word from beginning to the end of the string
if(str.match(/(^|\W)stack($|\W)/)) {
alert('Word Match');
}else {
alert('Word not found');
}
Check the fiddle
NOTE: For adding case sensitiveness update the regex with /(^|\W)stack($|\W)/i
Thanks