Richard C
Richard C

Reputation: 411

Find and Replace Regular Expression (NotePad++)

I'm looking at a global search and replace within NotePad++ which will look for the following text...

date and %c

examples would be...

date +%m-%d%H:%M:%S%c
date +%m-%d%H%c:%M:%S
date +%c-%m-%d%H:%M:%S

etc.

I can find the string by searching for date (.)+%c but I can't think for the life of me what the replacement would be. I want to replace %c with %z (or something else later on) and keep the remaining text.

Thanks for any help.

Upvotes: 1

Views: 196

Answers (2)

vks
vks

Reputation: 67968

(date.*?)%c

Replace by :$1%z

Upvotes: 1

Nemesis
Nemesis

Reputation: 2334

You can search for

date (.*?)%c(.*)

and replace it by

date $1%z$2

Output for your examples:

date +%m-%d%H:%M:%S%z
date +%m-%d%H%z:%M:%S
date +%z-%m-%d%H:%M:%S

Upvotes: 1

Related Questions