I need to find the text of all the one-digit number.
My code:
$string = \'text 4 78 text 558 my.name@gmail.com 5 text 78998 text\'; $pattern = \'/ [\
Search around word boundaries:
\b\d\b
As explained by the others, this will extract single digits meaning that some special characters might not be respected like "." in an ip address. To address that, see F.J and Mike Brant's answer(s).