Home > front end >  Seek out a regular expression matching string of them
Seek out a regular expression matching string of them

Time:09-20

Several string
A. "Daisy. Zheng 14:46:37 RequestDate: 2019/12/24 - & gt; 2020/1/2 NeedByDate: 2019/12/26 - & gt; 2020/1/3
"B. "Daisy. Zheng 21:23:33 RequestDate: 2020/01/24 - & gt; 2020/3/2
"
Want to remove the RequestDate behind the date range:
A: 2019/12/24 - & gt; 2020/1/2
B: 2020/01/24 - & gt; 2020/3/2

CodePudding user response:

 
Var STR="Daisy. Zheng 14:46:37 RequestDate: 2019/12/24 - & gt; 2020/1/2 NeedByDate: 2019/12/26 - & gt; 2020/1/3 ";
Var res=STR. Match (/? <=RequestDate: \ d {4} \ \ d {1, 2} \/\ d {1, 2} - & gt; \ d {4} \ \ d {1, 2} \/\ d {1, 2}/);
Alert (res [0]);

CodePudding user response:

Thank you for your quick reply!!!!! I want to formally,
Ask one more, if I want to find the matching a string of all other characters?

For example:

A: "Daisy. Zheng 14:46:37 NeedByDate: 2019/12/26 - & gt; 2020/1/3
"B: "Daisy. Zheng 21:23:33"

CodePudding user response:

 
Var STR="Daisy. Zheng 14:46:37 RequestDate: 2019/12/24 - & gt; 2020/1/2 NeedByDate: 2019/12/26 - & gt; 2020/1/3 ";
Var res=STR. Replace (/RequestDate: \ d {4} \ \ d {1, 2} \/\ d {1, 2} - & gt; \ d {4} \ \ d {1, 2} \/\ d {1, 2} \ s */, "");
Alert (res);
  • Related