this is what I have so far:
$data = "Hello this is on1";
if (preg_match("/n/", $data)){
$status = "it contains n";
}
if (preg_match("/n1/", $data)){
$status1 = "it contains n1";
}
echo $status;
echo $status1;
this will say that $data it contains “n” then that $data contains “n1”
the issue I am having is how do I grab “n” alone.
it should return “it contains n” only if $data="Hello this contains n";
in other terms the letter “n” should not be attached to ANY number, if it’s attached to something else that’s fine.
Use word boundaries
\band negative lookahead like this:\bwill make surenis matched with word boundaries henceon1will not be matched.