Home  >  Article  >  Backend Development  >  PHP method to implement regular replacement of punctuation marks with spaces

PHP method to implement regular replacement of punctuation marks with spaces

墨辰丷
墨辰丷Original
2018-05-18 15:22:331868browse

This article mainly introduces the method of replacing punctuation marks with spaces in PHP, and analyzes the operation skills related to regular matching of symbols in PHP in the form of examples. Friends in need can refer to the following

. The details are as follows:

<?php
$character = "!@#$%^&*中&#39;文中&#39;文中&#39;文().,<>|[]&#39;\":;}{-_+=?/abcdefgh中&#39;文ijklmnopqrstuvwx中&#39;文yzABCDEFGHI中文JKLMNOPQRSTUVWXYZ~`中&#39;文文文文文";
$reg = "/[[:punct:]]/i";
$character = preg_replace($reg, &#39; &#39;, $character);
print_r($character);
die;
?>

The running results are as follows:

中 文中 文中 文 abcdefgh中 文ijklmnopqrstuvwx中 文yzABCDEFGHI中文JKLMNOPQRSTUVWXYZ 中 文文文文文

Related recommendations:

PHP utilizesregularexpression matching provinces and cities

##PHPregularexpression theory

phpregularexpression about email verification

##

The above is the detailed content of PHP method to implement regular replacement of punctuation marks with spaces. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn