Hello,
There is such a code
<script> var str = 'Подъем в 06:50. Душ в 7-10. Зарядка в 7:30'; var re = /\d\d[-:]\d\d/g; alert(str.match(re)); </script> In IE9, an alert displays only the first match - 06:50. How to display all matches?
Hello,
There is such a code
<script> var str = 'Подъем в 06:50. Душ в 7-10. Зарядка в 7:30'; var re = /\d\d[-:]\d\d/g; alert(str.match(re)); </script> In IE9, an alert displays only the first match - 06:50. How to display all matches?
Try this:
var sample = 'Подъем в 06:50. Душ в 07-10. Зарядка в 07:30'; var re = /\d\d[-:]\d\d/g; var match = null; while (match = re.exec(sample)){ alert(match); } Note that in your line 7-10 and 7:30 do not have a zero at the beginning.
You can put \d{1,2} instead of \d\d
<script> var str = 'Подъем в 06:50. Душ в 7-10. Зарядка в 7:30'; var re = /\d{1,2}[-:]\d\d/g; alert(str.match(re)); </script> Source: https://ru.stackoverflow.com/questions/70431/
All Articles