Page 1 of 1

RegExp rename problem with spaces[EXPLAINED]

Posted: 15 May 2014 06:58
by bdeshi
Try to regexp rename this file with that pattern:

Code: Select all

"The        Spacious.txt"

Code: Select all

"^The > "
Only "the" should be replaced with "", but all those spaces are replaced too! Why? Fix how?

Sorry for two back-to-back reports, but found out about the other bug/confusion while testing this one.

EDIT:pattern typo+standardization

Re: RegExp rename problem with spaces

Posted: 15 May 2014 07:21
by Stefan
It is a MS design rule that a file name must not have leading spaces.
XY follow this rule. Only some managers, like DOS, allow to keep or add leading spaces.
There must be a post about this topic already somewhere...


And... why

Code: Select all

"^\t\h\e > "
?

One would simple use "^the > "

"\t" is a meta char to match a tab in RegEx.



- - -

If you really want to keep leading spaces, RegEx rename

Code: Select all

"^the\s > #"


while instead of # -sign you would hold the Alt-key and type 255 on the numpad.

This will exchange the space after 'the' with a "non-breaking space". (visit a ASCII table)




.

Re: RegExp rename problem with spaces

Posted: 15 May 2014 07:28
by bdeshi
Okay, thanks!

I know I don't have to escape literal alphabets, but the T was actually capital (typo) and the slashes escaped dots originally and were kept in.