RegEx是一种糟糕的时间格式 [英] RegEx for a bad time format
问题描述
嗨
试图在c#
中获取正则表达式我使用XPath连续循环遍历所有'td'单元格并且想要得到包含时间的单元格,但时间只有这种格式
一些例子
15h 9m
1h 3m
2h 34m
它永远不会超过24小时所以这不是问题...我真的不知道正则表达非常好,我正在努力。我有类似的东西
string t =15h 9m;
regex =新的正则表达式(@* h。* m );
match = regex.Match(t);
所以它的
1或2个字符一封信'h'
然后一个空格
然后一个或两个字符然后一个字母'm'
帮助赞赏
谢谢
尝试:
\d\d?h\s\d\d?米
Hi
Trying to get a regex for this in c#
Im using XPath to loop thorugh all 'td' cells in a row and want to get the cell that contains a time, but the time is only in this format
some examples
15h 9m
1h 3m
2h 34m
it will never be more that 24 hours so thats no an issue...I really dont know regex very well and am struggling. I have something like this
string t = "15h 9m";
regex = new Regex(@"*h.*m");
match = regex.Match(t);
so its
1 or 2 chars the a letter 'h'
then a space
then one or 2 chars then a letter 'm'
Help appreciated
Thanks
Try:
\d\d?h\s\d\d?m
这篇关于RegEx是一种糟糕的时间格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!