Regex 正则表达式添加填充零
我正在处理这个yahoo pipe正则表达式,我发现了一个我无法完全理解的bug 我有一个URL,我从中提取数字,对它们进行分类,制作一个img html标记并嵌入它。问题是,URL是以非填充方式显示的,但是链接的图像具有零。因此,当有一天或一个月是个位数时,正则表达式停止工作 这就是我到目前为止所做的:Regex 正则表达式添加填充零,regex,padding,yahoo-pipes,Regex,Padding,Yahoo Pipes,我正在处理这个yahoo pipe正则表达式,我发现了一个我无法完全理解的bug 我有一个URL,我从中提取数字,对它们进行分类,制作一个img html标记并嵌入它。问题是,URL是以非填充方式显示的,但是链接的图像具有零。因此,当有一天或一个月是个位数时,正则表达式停止工作 这就是我到目前为止所做的: The URL: http://www.penny-arcade.com/comic/2009/1/2/patently-ridiculous/ The RegEx: (\d{4})/(\d+
The URL: http://www.penny-arcade.com/comic/2009/1/2/patently-ridiculous/
The RegEx: (\d{4})/(\d+)/(\d+)
The Replacement: <img src="http://www.penny-arcade.com/images/$1/$1$2$3.jpg" />
What should appear: <img src="http://www.penny-arcade.com/images/2009/20090102.jpg" />
What appears: <img src="http://www.penny-arcade.com/images/2009/200912.jpg"/>
URL:http://www.penny-arcade.com/comic/2009/1/2/patently-ridiculous/
正则表达式:(\d{4})/(\d+)/(\d+)
替代品:
应显示的内容:
出现的内容:
我如何解析这些零以使其工作?如果可以使用多个正则表达式,这里有一个解决方法: search: (\d{4})/(\d)/ replace: $1/0$2/ search: (\d{4})/(\d{2})/(\d)/ replace: $1/$2/0$3/ search: (\d{2})/(\d{2})/(\d{2})/(.+)/ replace: <img src="http://www.penny-arcade.com/images/$1/$2$3.jpg" /> 搜索:(\d{4})/(\d)/ 替换:$1/0$2/ 搜索:(\d{4})/(\d{2})/(\d)/ 替换:$1/$2/0$3/ 搜索:(\d{2})/(\d{2})/(\d{2})/(.+)/ 替换:
删除了我的答案,因为我完全认为你是在.net上写的。我的错。是的,它只会确保先填充一位数的日期。