I\'m trying to replace numbers with optional, dash, dot or space from the start of a string, my pattern does not seem to work. I want to replace this:
01. PHP
0
Can try this
$t = "01. PHP";
$pattern = '/^[0-9\.\s\-]+/';
echo preg_replace($pattern, '', $t);
Output
PHP
Regex Explanation
^ assert position at start of the string
0-9 a single character in the range between 0 and 9
\. matches the character . literally
\s match any white space character [\r\n\t\f ]
\- matches the character - literally