Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular Expression: Remove the middle string

Tags:

regex

I have the following sentence:

**     DATE : 04/12/2014   * TIME: 07:49:42                **

I only want to capture 04/12/2014 07:49:42.

I've tried this .*DATE : ([0-9\/]+.*TIME: [0-9\:]+)

But I got this: "04/12/2014 * TIME: 07:49:42."

How can I remove " * TIME:"?

I need it in pure regex, so I'm testing at http://www.regexr.com/.

like image 861
Rodrigo Schemes Avatar asked Aug 30 '26 10:08

Rodrigo Schemes


1 Answers

[\* ]*Date\s*:\s*([0-9/]+)[ \*]*time\s*:\s*([0-9:]+)[ \*]*

in replace statement u use $1 $2 then you will get what you want

like image 72
parthi Avatar answered Sep 01 '26 07:09

parthi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!