Replace digits after !

A swapping-ground for Regular Expression syntax

Replace digits after !

Postby Fess » Fri Oct 28, 2016 6:13 pm

Hi,

I have thousands of files which need to have the two digits (not constant) after the exclamation point (this is a constant) in the middle of a filename changed to QB.

Example:

First_Last_!303405.pdf changed to:
First_Last_!QB3405.pdf

I've tried
Match: (!\d{2})
Replace QB
but this just replaces the whole filename with QB.pdf

Any helpl would be appreciated.
Al
Fess
 
Posts: 2
Joined: Thu Oct 27, 2016 6:59 pm

Re: Replace digits after !

Postby KenP » Fri Oct 28, 2016 6:35 pm

This should do what you want.

RegEx (1)
Match: ^(.*!)(\d{2})(.*)
Replace: \1QB\3
KenP
 
Posts: 199
Joined: Sat Jul 30, 2016 11:25 am

Re: Replace digits after !

Postby Fess » Mon Oct 31, 2016 3:59 pm

Indeed it does!
This was a good way to start a Monday.
Thank you.
Fess
 
Posts: 2
Joined: Thu Oct 27, 2016 6:59 pm


Return to Regular Expressions