0

次の文字列があるとします。

$string = 'Th1s 1s my 5tr1ng with a timestamp 1357002120 and another timestamp here 1357002120.';

私が望むのは、2 つのタイムスタンプなしで文字列を返すことですが、他の数字はそのままにしておくことです。

したがって、出力は次のようになります。

「Th1s 1s my 5tr1ng with a timestamp and another timestamp here.」

ある種の正規表現でそれができると思いますが、どこから始めればよいかわかりません。

4

1 に答える 1

3

後で独自に開発できるシンプルなソリューション:

<?php
$string = 'Th1s 1s my 5tr1ng with a timestamp 1357002120 and another timestamp here 1357002120.';
echo preg_replace("#\d{10,11}#", "", $string);
?>
于 2013-07-17T06:36:44.050 に答える