PHP regular replacement of punctuation marks with spaces

小云云
Release: 2023-03-19 18:20:01
Original
2057 people have browsed it

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 it. I hope it can help everyone.


<?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;
?>
Copy after login

The running results are as follows:


中 文中 文中 文 abcdefgh中 文ijklmnopqrstuvwx中 文yzABCDEFGHI中文JKLMNOPQRSTUVWXYZ 中 文文文文文
Copy after login

Related recommendations:

php characters Detailed explanation of string regular replacement function preg_replace

JavaScript regular replacement HTML tag function sample code sharing (picture)

php regular replacement variable specified character Methods

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!