,比如我有以下字符串:PHP:PCRE:如何替换重复字符
a_b__c___d____e
如何的preg_replace焦炭_为char ' - ',但只有部分 '__...' 包含超过N重复_。
我希望你能理解我))
source: a_b__c___d____e
cond: change '_' where 2 or more
result: a_b--c---d----e
或
source: a_b__c___d____e_____f
cont: change '_' where 4 or more
result: a_b__c___d----e-----f
谢谢!
p.s.有趣的解决方案,不使用循环。如何用循环来实现它(我认为)知道任何人。只是一个正则表达式和preg_replace。