我预测您的模式会让您失望而不是让您满意(或者您对项目范围内的“过度匹配”感到非常满意)。虽然我的建议确实超出了模式长度,但(*SKIP)(*FAIL)通过消耗和丢弃需要取消资格的子字符串,一种技术可以很好地为您服务。可能有一种方法可以通过环视来指示模式逻辑,但是由于初始模式中有如此多的潜在漏洞且没有样本数据,因此变量太多,无法提出自信的建议。代码:$text = <<<TEXTA number 555555555 then some more text and a quoted number "(123)4567890" andthen 1 2 3 4 6 (54) 3 -2 and forward slashed /+--------0/ versus+--------0 then something more realistic '234 588 9191' no more text.This is not closed by the same character on bothends: "+012345678901/ which of course is a _necessary_ check?TEXT;echo preg_replace( '~([\'"/])\+?[\d()\s-]{8,25}\d{1,2}\1(*SKIP)(*FAIL)|((?!\s)\+?[\d()\s-]{8,25}\d{1,2})~', "<strong>$2</strong>", $text);输出:A number <strong>555555555</strong> then some more text and a quoted number "(123)4567890" andthen <strong>1 2 3 4 6 (54) 3 -2</strong> and forward slashed /+--------0/ versus <strong>+--------0</strong> then something more realistic '234 588 9191' no more text.This is not closed by the same character on bothends: "<strong>+012345678901</strong>/ which of course is a _necessary_ check?有关技术细分,请参阅 Regex101 链接。否则,这是有效地检查“电话号码”(由最初的模式),如果它们被包裹',"或/则匹配被忽略,正则表达式引擎继续寻找那个子后的比赛。我(?!\s)在您的电话模式的第二次使用开始时添加了,以便在替换时省略前导空格。