Home > front end >  Help: javascript use regular expressions to extract a date, thank you!
Help: javascript use regular expressions to extract a date, thank you!

Time:01-24

Need to be in a text to extract , can only use javascript regular expression, but I do not, a great god can do me a favor?
The text is as follows:

Has been transferred to the 2020-02-26 14:46:04 to send Internet company 2020-02-26 14:51:58 with loading large transport unit 2020-02-26 14:54:14 with transport 14:55:16 transport in 2020-02-26 at the Internet company (13949) liao mHj9552020-02-26 15:11:26 to-do knot at (139419) the liao mHj955 2020-02-27 08:42:01 has been transferred to sales department settlement unit

The date of the above red words,
Thank you very much!

CodePudding user response:

Var STR="has been transferred to the 2020-02-26 14:46:04 to send Internet company 2020-02-26 14:51:58 with loading large transport unit 2020-02-26 14:54:14 with transport 14:55:16 transport in 2020-02-26 at the Internet company (13949) liao mHj9552020-02-26 15:11:26 to-do knot at (139419) liao mHj9552020-02-27 08:42:01 has been transferred to sales department settlement unit";
Var date=(STR) match (/\ d {4} - \ d {2} {2} - \ d/g) | | []). The pop ();
alert(date);
  • Related