Page 1 of 1

RegEx for "From Character to end of name"

PostPosted: Tue Apr 19, 2005 7:20 pm
by HerbFeldman
I want to use RegEx to pick out portions of a list of folder names for re-naming using a Find&Replace. Each name has extraneous characters at the end.
Example:

Ramma V1 - ABCDEF
Lamma V6 - FGHIJ
Gamma V8 - XYZ

I want to get all characters from the DASH to the end of the name, including the DASH. Can I do this with regular expressions?

PostPosted: Tue Apr 19, 2005 9:00 pm
by Smite
In most RegEx find and replace aps, you could do the following:
(-.*)
Then, \1 would produce the matching portion of the string.

This really has nothing to do with NewsBin RegEx though, since there's no "replace" type functionality...

PostPosted: Tue Apr 19, 2005 9:17 pm
by Kiltme
Using Flexible Rename (cool and free) http://hp.vector.co.jp/authors/VA014830/english/FlexRena/

The regexp find ".+- " and replace with "" will turn those into

ABCDEF
FGHIJ
XYZ

Which is what I think you were asking to do.

If you really meant "get rid of" instead of "get" the stuff after the " - " The regexp find " -.+" and replace with "" will turn those into

Ramma V1
Lamma V6
Gamma V8

The ".+" is any number of any character in it's regexp implementation.

PostPosted: Wed Apr 20, 2005 12:11 am
by HerbFeldman
Smite wrote:In most RegEx find and replace aps, you could do the following:
(-.*)
Then, \1 would produce the matching portion of the string....


Thanks, I'll try it and see if I can get it to work.

Smite wrote:This really has nothing to do with NewsBin RegEx though, since there's no "replace" type functionality...


True. However, the descript.ion file I use to create the file folder names is created by Newsbin, and I guessed that somebody here would be able to help me figure this out... and I was right!

PostPosted: Wed Apr 20, 2005 12:18 am
by HerbFeldman
Kiltme wrote:Using Flexible Rename (cool and free) http://hp.vector.co.jp/authors/VA014830/english/FlexRena/

The regexp find ".+- " and replace with "" will turn those into

<snip>

The ".+" is any number of any character in it's regexp implementation.

I'll try this one as well. Everything I can learn about regex will come in handy sooner or later.

Thanks for the tip about Flexible Rename. There's lots of renamers, but only a few will do folders as well.

PostPosted: Wed Apr 20, 2005 7:45 am
by dexter
In Perl, I'd do s/(.+) (- .+)/$1/ This would take everything up to the space before the dash and return it in $1 built in variable. The "s" specifies substitution so the result would only be the text to the left of the hyphen (except the space). If you want to know what was after the hyphen, look at the $2 built in variable.

PostPosted: Wed Apr 20, 2005 11:55 pm
by Smite
For a regex renamer, I highly recomend Shell Renamer, avaliable here:
http://www.codeproject.com/shell/shswapl.asp

It will do directories, but in order to get the option to bring this up, you must also highlight a file, and right-click on the file. After that, you can always deselect the file from the list.