How to remove the end of a filename with regex

A swapping-ground for Regular Expression syntax

How to remove the end of a filename with regex

Postby bromdon » Thu Aug 20, 2015 2:44 pm

Okay, it's been too long since I programmed to wrap my head around this any more.

I've a load of files (ABR brushes for PhotoShop) many of which have a filename ending " by fred" or " by wilma" or somesuch.

What I want to do is strip out all these different endings, going from the " by" part of the filename to the end of the filename.

So...is this possible with some kind of regular expression and wildcard? If so, can someone give me the key?

Cheers
bromdon
 
Posts: 1
Joined: Thu Aug 20, 2015 2:41 pm

Re: How to remove the end of a filename with regex

Postby Stefan » Thu Aug 20, 2015 5:47 pm

FROM:
Brush Abc by fred.abr
DEF brush by wilma.abr

TO:
Brush Abc.abr
DEF brush.abr


Try

RegEx(1)
Find: ^(.+) by.+$
Repl: \1



 
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU


Return to Regular Expressions