由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - RegEx puzzle
相关主题
如何 replace这里的第二个x要不要学习 scripting languages such as Python?
re一问from beautiful code
请教一个变态的regular expression 替换regex question
any way to use regex in Fortran?any perl html parser to recommend?
匹配问题 (转载)GCC TR1 实现regex 没?
装完boost之后还要再装REGEX吗?江湖救急
[合集] regular expression for whitespace in path[合集] 统一的regex (grep, sed, awk, python,..)
Can someone help me a quick regex?string /File IO processing using C
相关话题的讨论汇总
话题: 01话题: field话题: regex话题: 09话题: puzzle
进入Programming版参与讨论
1 (共1页)
c**t
发帖数: 2744
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
~
~
c**t
发帖数: 2744
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
: ~
: ~

c**t
发帖数: 2744
3
thanks, ${1} is the key!!
c**t
发帖数: 2744
4
maybe using replace multiple times..
c**t
发帖数: 2744
5
多次替换可以, 一次替换有难度
1 (共1页)
进入Programming版参与讨论
相关主题
string /File IO processing using C匹配问题 (转载)
用sscanf读入一段text中的电话号码,formatter怎么写?装完boost之后还要再装REGEX吗?
regular expression[合集] regular expression for whitespace in path
如何提取大批html文件中规则的信息?Can someone help me a quick regex?
如何 replace这里的第二个x要不要学习 scripting languages such as Python?
re一问from beautiful code
请教一个变态的regular expression 替换regex question
any way to use regex in Fortran?any perl html parser to recommend?
相关话题的讨论汇总
话题: 01话题: field话题: regex话题: 09话题: puzzle