如何在 Perl 中替换日期? [英] How to substitute dates in Perl?
本文介绍了如何在 Perl 中替换日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
perl -pi.back -e 's/2013/07/31-05:54:14/2014/07/31-00:00:00/g;' /tmp/ranjan/replace.SEL
我正在使用上面的一行来替换从 2013/07/31-05:54:14
到 2014/07/31-00:00:00代码>.但我做不到.我只能找到字符串的替代,而不是上述格式的数字.请帮帮我.
I'm using the above one liner to replace the date from 2013/07/31-05:54:14
to 2014/07/31-00:00:00
. But I'm unable to do it. I'm able to find only substitution for string not for numbers which are in the above format . please help me out.
推荐答案
使用 替代方案分隔符:
s{find}{replace}g;
或
s#find#replace#g;
否则你必须转义所有的 /
.
Otherwise you'd have to escape all the /
.
这篇关于如何在 Perl 中替换日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文