如何使用Perl将冒号放入字符串中最后两个字符?

前端之家收集整理的这篇文章主要介绍了如何使用Perl将冒号放入字符串中最后两个字符?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试找到一种方法将冒号(:)放入一个字符串中,字符串末尾有两个字符.

$meetdays的例子:
1200 => 12:00900 => 9:001340 => 13:40

不确定这应该是正则表达式还是我不知道的另一个函数.

解决方法

s/(?=..$)/:/

不要使用roe对$&的建议. perldoc perlvar:

The use of this variable anywhere in a program imposes a considerable performance penalty on all regular expression matches. See “BUGS”.

猜你在找的Perl相关文章