Home > Backend Development > PHP Tutorial > 如何去除字符串中非汉字、非字母、非数字的字符?

如何去除字符串中非汉字、非字母、非数字的字符?

WBOY
Release: 2016-06-23 14:01:44
Original
1385 people have browsed it

如何去除字符串中非汉字、非字母、非数字、非常见标点符号(逗号,句号,反斜杠)的所有字符

如:4/13の困扰(☀,∴…3???...?三Ⅲ) ??爱我中华= =扬我国威【转】

过滤后:4/13困扰9728爱我中华 扬我国威转


回复讨论(解决方案)

字符串替换或是正则匹配

我就是想请教这个正则要如何写?

你意思是只要数字英文字母喽?
preg_match("/^[a-z0-9]+[^_]$/g",$a);没测 手写. 自己看下类库

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