【发布时间】:2012-09-05 06:28:28
【问题描述】:
$string = " Some string ";
//the output should look like this
$output = "___Some string__";
所以每个前导和尾随空格都替换为下划线。
我在这里找到了 C 中的正则表达式:Replace only leading and trailing whitespace with underscore using regex in c# 但我无法让它在 php 中工作。
【问题讨论】:
标签: php regex preg-replace whitespace