【发布时间】:2012-04-06 21:02:23
【问题描述】:
我有一个类似2005:10:29 12:23:53 的字符串,我希望只用- 替换出现的前两次:
预期结果2005-10-29 12:23:53
编辑:
我在 KDE 的 krename 工具中需要这个正则表达式,我无法编辑/格式化原始的 [exifExif.Image.DateTime] 女巫返回不需要的 2005:10:29 12:23:53 格式,但是有一个 Find and Replace 来后处理字符串
(?<=\d{4}):|:(?=\d{2}\s) 完成 on rubular 的工作,但在 KDE 中没有 :(
我相信还有更多的解决方案。
编辑:
:(?=\d{2}:\d{2}\s)|:(?=\d{2}\s) 甚至可以在 KDE 上工作
阅读后找到了这个解决方案
You can use a full-fledged regular expression inside the lookahead.
Most regular expression engines only allow literal characters and
alternation inside lookbehind, since they cannot apply regular
expression backwards.
【问题讨论】:
-
那么您想使用什么语言?您刚刚删除了 JavaScript 和 Ruby...
-
我想你最好问问 krename 支持:krename.net/Mailinglist.14.0.html