avatar
c*t
1
$s = '7/1/2007 1:20,field 2,6/9/2006 2:9,field 3,1/1/2008 12:9';
try to convert it to
'07/01/2007 01:20,field 2,06/09/2006 02:09,field 3,01/01/2008 12:09'
how to write reguler expression to replace?
$x =~ s![^01-9]?(\d)([/:]+)!0$1$2!g; # removed , and empty space
~
~
avatar
c*t
2
$x =~ s!([^0-9]?[1-9])([/:,]+)!0$1$2!g; #doesn't work either

【在 c**t 的大作中提到】
: $s = '7/1/2007 1:20,field 2,6/9/2006 2:9,field 3,1/1/2008 12:9';
: try to convert it to
: '07/01/2007 01:20,field 2,06/09/2006 02:09,field 3,01/01/2008 12:09'
: how to write reguler expression to replace?
: $x =~ s![^01-9]?(\d)([/:]+)!0$1$2!g; # removed , and empty space
: ~
: ~

avatar
c*t
3
thanks, ${1} is the key!!
avatar
c*t
4
maybe using replace multiple times..
avatar
c*t
5
多次替换可以, 一次替换有难度
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。