I have the following function to do a "exact match"
of a pattern($searchPat)
in a sentence ($sourceStr)
function isUsed($sourceStr, $searchPat) {
if (strpos($sourceStr, $searchPat) !== false) {
return true;
} else {
return false;
}
}
However, this doesn't do an exact match. I changed the function as follows but this doesn't even execute.
function isUsed($sourceStr, $searchPat) {
if (preg_match("~\b[$sourceStr]\b~", $searchPat)) {
return true;
} else {
return false;
}
}
How could I do an exact match please?