Page 1 of 1

Remove text between 2 characters

PostPosted: Tue Aug 28, 2018 10:29 am
by sbree
Hi,

I am trying my best to learn Regex but I still suck. I would appreciate if someone can assist me.

I have a file name:
3052503155104.Bourjois_FDTAirMat_01_1.png

I would like to keep everything before the first . and erase everything until the last _
so the desired output would be 3052503155104_1.png
I want to remove the . as well but keep the _

so
3052503155104.Bourjois_FDTAirMat_01_1.png
3052503155104.Bourjois_FDTAirMat_01_2.png
3052503155104.Bourjois_FDTAirMat_01_3.png

becomes
3052503155104_1.png
3052503155104_2.png
3052503155104_3.png

Would greatly appreciate your help.

P.S - I don't want to use the prevent duplicate feature as a workaround.

Re: Remove text between 2 characters

PostPosted: Tue Aug 28, 2018 3:37 pm
by Tolek12
Use regex box in the gui
match:
Code: Select all
(^.*?)\.(.*?)(_\d$)

replace:
Code: Select all
\1\3

include ext should be unchecked.

If you have problems with regex just go to Regex101 and try things out : https://regex101.com/r/F4gaEE/2

Re: Remove text between 2 characters

PostPosted: Tue Aug 28, 2018 4:25 pm
by therube
(Heh. Didn't realize it was answered. Anyhow, my take...)

1:RegEx:
Code: Select all
Match:  (.*?)_(.*)_(.*)
Replace:  \1_\3


Oh, & now looking at yours, I see I didn't even read what the OP was looking for correctly, so what I have above is wrong.