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

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -