1

次のようなテキスト ファイルがあります。

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
4

2 に答える 2

3

正規表現を使用します。

$str = 'What word is on page 9, 4 words from the left on line 15?   account';
echo preg_replace('/\?\s+/', '?', $str);
于 2013-02-11T17:51:24.330 に答える
1
$input = 'What word is on page 9, 4 words from the left on line 15?   account';
echo preg_replace('/\?\s+/', '?', $input);

実際に見てください

于 2013-02-11T17:52:19.307 に答える