I have a string txt='2017-04-01 and 2017-04-04' and i need to get the dates from the string.
I've tried with txt.match(/(\d{4})-(\d{2})-(\d{2})\s+/) but i get:
[
"2017-04-01 ",
"2017",
"04",
"01"
]
off course that i need
[
"2017-04-01",
"2017-04-04"
]
Thanks.
\s+and add/gmodifier -txt.match(/\d{4}-\d{2}-\d{2}/g). You may add word boundaries\bif you need a "whole word" match.