我有一个看起来像这样的文本文件:
What word is on page 9, 4 words from the left on line 15? account
What word is on page 11, 2 words from the left on line 5? always
有没有办法可以删除“?”之后的所有空格所以它看起来像这样(整个实际文本文件中的空间量都是不同的):
What word is on page 9, 4 words from the left on line 15?account
What word is on page 11, 2 words from the left on line 5?always
答案 0 :(得分:2)
使用正则表达式:
$str = 'What word is on page 9, 4 words from the left on line 15? account';
echo preg_replace('/\?\s+/', '?', $str);
答案 1 :(得分:1)
$input = 'What word is on page 9, 4 words from the left on line 15? account';
echo preg_replace('/\?\s+/', '?', $input);