php method to use regular numbers to replace numbers: first create a PHP sample file and set the file encoding; then use "preg_replace($reg, $after, $str);" to implement the function of regular number replacement; Finally execute the file.
Recommended: "PHP Video Tutorial"
'; $reg = '/((0|[1-9]\d*)(\.\d+)?)|(零|一|二|三|四|五|六|七|八|九|十)(百|十|零)?(一|二|三|四|五|六|七|八|九)?(百|十|零)?(一|二|三|四|五|六|七|八|九)?/'; $after = '***'; $newstr = preg_replace($reg, $after, $str); echo $newstr . '
';
Output results
Regular expression matching Chinese numbers
$rule='/(零|一|二|三|四|五|六|七|八|九|十)(百|十|零)?(一|二|三|四|五|六|七|八|九)?(百|十|零)?(一|二|三|四|五|六|七|八|九)?/';
The above is the detailed content of How to use regex to replace Chinese numbers in php. For more information, please follow other related articles on the PHP Chinese website!