Gabriel_Espinoza
asked on
REGEX of a HTML to get Hours
Hi all
I have the following string:
I can receive any hours indicated in the string.
Is there a way of getting an array of "hours" by using Regular Expressions?
I mean something like
in advance, many many thanks!
I have the following string:
08:00<BR><DIV style="COLOR: red">17:00</DIV>
I can receive any hours indicated in the string.
Is there a way of getting an array of "hours" by using Regular Expressions?
I mean something like
var from = "08:00<BR><DIV style="COLOR: red">17:00</DIV>";
var to = from.match("fill_with_regular_expression");
// to[0] = "08:00"
// to[1] = "17:00"
in advance, many many thanks!
ASKER
Thank you for the fast reply,
I know I should use the "g" to list all matched elements. It was my bad for not pointing it out.
Now, could you help me with the regular expression?
I know I should use the "g" to list all matched elements. It was my bad for not pointing it out.
Now, could you help me with the regular expression?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
var to = from.match(/\d{1,2}:\d{1,2}/g)
ASKER
thank you all for the fast reply.
I tried all the expression you posted, none of them returned anything. I'm still getting a null.
Any more ideas?
I tried all the expression you posted, none of them returned anything. I'm still getting a null.
Any more ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you very much, it was my mistake cause I was using cuotes to pass the regex as parameter.
Thank you very much
Thank you very much
NP. Glad to help : )
>> var all = from.match("fill_with_regu
Number of matches will be all.length
http://freewebdesigntutorials.com/javaScriptTutorials/jsRegularExpressionObject/regExpGlobalProperty.htm