繁体   English   中英

在php中使用preg_replace删除php中的空间

[英]using preg_replace in php to remove space in php

我有以下字符串+ Example + Test + Test2并使用preg_replace我想得到以下结果+Example +Test +Test2

我一直在尝试使用以下代码

preg_replace("/\s*([\+])\s*/", "$1", $string)

但是这个回来了

+Example+Test+Test2
$output = str_replace('+ ', '+', $input);

要么

$output = preg_replace('/\\+\\s+/', '+', $input);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM