javascript - RegExp stumper, should be simple -


i'm regexp, 1 has me stumped. here's javascript snippet:

var justdateregex = '\d+/\d+/\d+'; var datestr = $('#dropdown').find(':selected').text(); var onlydate = datestr.match(justdateregex); console.log('regex: ' + justdateregex + ' datestr: ' + datestr + ' onlydate: ' + onlydate); 

here's output console.log

regex: d+/d+/d+ datestr: 11/23/2013 12:00:00 onlydate: null 

i expect onlydate read: 11/23/2013, null. ideas why?

string.match() expects parameter regexp object, not string.

var justdateregex = /\d+\/\d+\/\d+/; var datestr = $('#dropdown').find(':selected').text(); var onlydate = datestr.match(justdateregex); 

Comments

Popular posts from this blog

Line ending issue with Mercurial or Visual Studio -

c# - Delving into the world of XML (Windows Phone) Error I dont understand (The ' ' character, hexadecimal value 0x20, cannot be included in a name.) -

python - Received unregistered task using Celery with Django -