php regex:删除双倍以上的空格 [英] php regex: removing more than double space
本文介绍了php regex:删除双倍以上的空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$tags = preg_replace('/\s\s+/',' ', $tags);
这将删除不止一个空格?
that will remove more than just one space ?
我需要删除超过两倍的空格.
i need to remove anything more than double space.
推荐答案
我认为超过两倍的空格"是指 3 个或更多的空格:
I'm taking "more than double space" to mean 3 or more spaces:
$tags = preg_replace('/\s{3,}/',' ', $tags);
这将用一个空格替换 3 个或更多连续出现的任何空白字符.
This will replace 3 or more contiguous occurrences of any whitespace character with a single space.
这篇关于php regex:删除双倍以上的空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文