PHP清除字符串中空白正则表达式
先利用trim系列函数来删除左右空格
代码如下 | 复制代码 |
trim 去除一个字符串两端空格, echo trim(" 空格 ")." ?> |
删除所有空格不能使用php trim()函数,因类他也只能是去除两边空闲
代码如下 | 复制代码 |
|
上面只能删除是一些常见的空格了,下面分享一个更具体的。
代码如下 | 复制代码 |
$str = " This line containstliberal rn use of whitespace.nn"; // First remove the leading/trailing whitespace // Now remove any doubled-up whitespace // Finally, replace any non-space whitespace, with a space // Echo out: 'This line contains liberal use of whitespace.' {$str} Nach dem Login kopieren |
中间就是利用了替换连续空格与左右空格之后再利用preg_replace替换去除重复的,然后再用另一个正则表达式[nrt]来查找任何残余的换行符(n), 回车(r), 或制表符(t) 即可。
永久链接:
转载随意!带上文章地址吧。

Heiße KI -Werkzeuge

Undresser.AI Undress
KI-gestützte App zum Erstellen realistischer Aktfotos

AI Clothes Remover
Online-KI-Tool zum Entfernen von Kleidung aus Fotos.

Undress AI Tool
Ausziehbilder kostenlos

Clothoff.io
KI-Kleiderentferner

AI Hentai Generator
Erstellen Sie kostenlos Ai Hentai.

Heißer Artikel

Heiße Werkzeuge

Notepad++7.3.1
Einfach zu bedienender und kostenloser Code-Editor

SublimeText3 chinesische Version
Chinesische Version, sehr einfach zu bedienen

Senden Sie Studio 13.0.1
Leistungsstarke integrierte PHP-Entwicklungsumgebung

Dreamweaver CS6
Visuelle Webentwicklungstools

SublimeText3 Mac-Version
Codebearbeitungssoftware auf Gottesniveau (SublimeText3)

Heiße Themen

