假设我有以下字符串:
$string = 'Th1s 1s my 5tr1ng with a timestamp 1357002120 and another timestamp here 1357002120.';
我想要的是返回一个没有两个时间戳的字符串,但保留其他任何数字。
所以,输出应该是:
' Th1s 1s我的5tr1ng带有时间戳和另一个时间戳。'
我认为某种正则表达式可以做到,但我不知道从哪里开始。
答案 0 :(得分:3)
您可以在以后开发自己的简单解决方案:
<?php
$string = 'Th1s 1s my 5tr1ng with a timestamp 1357002120 and another timestamp here 1357002120.';
echo preg_replace("#\d{10,11}#", "", $string);
?>