boards

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