1

Basically, I have a string like this:

text text text text text 1/12/2012 text text text text

I need to somehow get that date out of the string. I'm terrible with regular expressions, and I was wondering if there's an easy way to get it with jQuery.

1 Answer 1

6

You don't need jQuery for this, just use a regular expression, eg.

/\d{1,2}\/\d{1,2}\/\d{4}/.exec('text text 1/12/2012 text text')

Note, that this only extracts strings that look like a date and they may be invalid.

Sign up to request clarification or add additional context in comments.

1 Comment

The exec function returns an array, so you will need to use tdate[0] to get the matched part of the string.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.