![](/img/trans.png)
[英]Remove white space from entire Html but inside pre with regular expressions in php
[英]Regular expressions to remove space and whitespace in PHP?
我正在尋找正則表達式以刪除逗號前后的空格和空白。
嘗試這個:
$output = preg_replace('/\s*,\s*/', ',', $str);
這將用一個逗號將所有逗號替換為可能的前導和尾隨空格字符( \\s
)。
preg_replace('/\s*,\s*/', ',', $target_string);
您不需要正則表達式。
$output = explode(',', $input);
$output = array_map('trim', $output);
$output = implode(',', $output);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.