Delete everything after date on Atom using Regex

Viewed 226

I have the following dates:

2020-09-01,13:23:29.000+0000
2020-07-22,13:13:48.000+0000
2020-01-09,21:58:48.000+0000

I wonder how can I just keep the date in atom, the result should be like:

2020-09-01
2020-07-22
2020-01-09

I tried to find all ^(.*?)\s,.*$ and then replace by $1 which was not working.

2 Answers

With your shown samples, could you please try following. Online demo is: Online regex demo

^\d{4}(?:-\d{2}){2}

Explanation: ^\d{4} checking condition if it starts with 4 digits followed by a non-capturing group of (-\d{2}){2} which means a dash followed by 2 digits and this group comes 2 times match that pattern.

/^\d\d\d\d-\d\d-\d\d/ 

or

/^\d{4}-\d{2}-\d{2}/
Related