-2

I have multiple strings I want to loop through and check if any match the below format (unix timestamp, space, d/m/Y)

1513592758 18/12/2017

I have been using https://regexr.com/ to test and the closest I have gotten is using the below

([0-9]) (0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d 

but this still does not give me an exact match.

Any help would be much appreciated!

3
  • 2
    A + after the first [0-9] should help. Commented Aug 31, 2018 at 10:50
  • 1
    Programming languages usually support date string to date object conversion, why not leverage that? What programming language are you using here? Commented Aug 31, 2018 at 10:51
  • Probably a dupe of RegEx - Match Numbers of Variable Length Ask Question Commented Aug 31, 2018 at 11:17

1 Answer 1

0

You are soo close

([0-9]+) (0[1-9]|[12][0-9]|3[01])[ /.-](0[1-9]|1[012])[ /.-](19|20)\d\d 

The plus means: one or more of the preceding character (class)

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.