Click here to Skip to main content
15,891,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Posted
Updated 6-Aug-15 11:52am
v2
Comments
Patrice T 6-Aug-15 17:14pm    
What about learning RegEx ?
RaisKazi 6-Aug-15 17:37pm    
You need this.
https://www.google.com/?gws_rd=ssl#q=online+regex
PIEBALDconsult 6-Aug-15 17:56pm    
http://www.codinghorror.com/blog/2009/11/parsing-html-the-cthulhu-way.html

1 solution

Try:
\d\d?h\s\d\d?m
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900