$string = "On 0 8 February 2 0 1 4 , he visited the fair";
我想更换号码之间的空间,所以它成为"On 08 February 2014, he visited the fair"
搜索和在Perl的正则表达式动态替换
我怎样才能做到这一点与正则表达式?我可以按索引做一个for循环索引,但是如果给出大量的文本,它会很慢。
这是我想要实现一个想法:
$string =~ s/([0-9]\s)+/substr($string,$-[0],$+[0]-$-[0])/g;
但由于SUBSTR不作为正则表达式中的一个函数处理它不会工作。有任何想法吗?
我做这个$ string =〜s/[0-9] \ K [] +(?= [[:punct:] 0-9])// xg; – Jean 2014-09-03 07:54:22