This article mainly introduces the method of replacing punctuation marks with spaces in PHP. It analyzes the operation skills related to regular matching of symbols in PHP in the form of examples. Friends in need can refer to the examples of this article.
Describes how PHP implements regular replacement of punctuation marks with spaces. Share it with everyone for your reference, the details are as follows:
<?php $character = "!@#$%^&*中'文中'文中'文().,<>|[]'\":;}{-_+=?/abcdefgh中'文ijklmnopqrstuvwx中'文yzABCDEFGHI中文JKLMNOPQRSTUVWXYZ~`中'文文文文文"; $reg = "/[[:punct:]]/i"; $character = preg_replace($reg, ' ', $character); print_r($character); die; ?>
The running results are as follows:
中 文中 文中 文 abcdefgh中 文ijklmnopqrstuvwx中 文yzABCDEFGHI中文JKLMNOPQRSTUVWXYZ 中 文文文文文
The above is the detailed content of Example of how to replace regular punctuation marks with spaces in PHP. For more information, please follow other related articles on the PHP Chinese website!