我希望使用RegEx从以下 141d 3h 2m 54s 。 2016-04-07 18:59:59 CDT(141d 3h 2m 54s from now)
答案 0 :(得分:0)
如果格式不变,这将为您提供所需
(?<=\().+s
实际上,有趣的是 -
\((.+s)
将其减少到17步。
答案 1 :(得分:0)
这适用于Oracle,也许您可以调整正则表达式以使用您正在使用的任何语言。
select regexp_replace('2016-04-07 18:59:59 CDT (141d 3h 2m 54s from now)',
'.*\((.*s) .*', '\1')
from dual;
答案 2 :(得分:0)
Match match;
match = Regex.Match(input string,@"\d+d\s+\d+h\s+\d+m\s+\d+s");
match.value为您提供所需的答案