Page 1 of 1
Bug or Feature: Search/Replace Rename for Xx --> XX won't work with odd number of X's
Posted: 17 Feb 2017 14:53
by Jerry
When there are an
odd number of the same letter in a row, with all but the last letter uppercase, search and replace of "Xx" to "XX" does not change the last lowercase character. For example using the expression "Xx/XX" in
Rename Special > Search and Replace,
- XXx-abx.txt does not change at all
XXx-Xx-abx.txt changes to XXx-XX-ab.txt instead of XXX-XX-abx.txt
XXXx-abx.txt changes to XXXX-abx.txt [ok]
XXXXx-abx.txt does not change at all
XXxxx-abx.txt changes to XXXXx-abx.txt instead of XXXXX-abx.txt
So if this is a feature and not a bug, I have to do one rename of Xx/XX for even counts and XXx/XXX for the odd counts?
[Using 17.50.0218]
Re: Bug or Feature: Search/Replace Rename for Xx --> XX won't work with odd number of X's
Posted: 17 Feb 2017 15:41
by admin
Confirmed! Fascinating!!

Going to work...

Re: Bug or Feature: Search/Replace Rename for Xx --> XX won't work with odd number of X's
Posted: 17 Feb 2017 16:04
by Gandolf
I don't totally agree with the last example.
I think that XXxxx-abx.txt should change to XXXxx-abx.txt, unless you are talking about a recursive replace.
I'm not on a system that will run XY at the moment so can't read the help file to see if the function is recursive by default.
Re: Bug or Feature: Search/Replace Rename for Xx --> XX won't work with odd number of X's
Posted: 17 Feb 2017 16:10
by admin
Not as fascinating as I thought but simply a user error. For this to work the replacement should be
case-sensitive!
It's done with a switch like this:
And
Gandolf is right, XXxxx-abx.txt is renamed to XXXxx-abx.txt. All others end up with all capital Xs.
Re: Bug or Feature: Search/Replace Rename for Xx --> XX won't work with odd number of X's
Posted: 17 Feb 2017 16:13
by Jerry
Gandolf wrote:I think that XXxxx-abx.txt should change to XXXxx-abx.txt, unless you are talking about a recursive replace.
Actually, I think I agree with you on that; not sure why I included that example.
Re: Bug or Feature: Search/Replace Rename for Xx --> XX won't work with odd number of X's
Posted: 17 Feb 2017 16:20
by Jerry
admin wrote:All others end up with all capital Xs.
With
out the /c switch, right?
Re: Bug or Feature: Search/Replace Rename for Xx --> XX won't work with odd number of X's
Posted: 17 Feb 2017 16:40
by admin
No, with the switch.
Re: Bug or Feature: Search/Replace Rename for Xx --> XX won't work with odd number of X's
Posted: 17 Feb 2017 17:42
by Jerry
Are you saying there is no bug here afterall?
Re: Bug or Feature: Search/Replace Rename for Xx --> XX won't work with odd number of X's
Posted: 17 Feb 2017 17:47
by highend
There isn't.
Re: Bug or Feature: Search/Replace Rename for Xx --> XX won't work with odd number of X's
Posted: 17 Feb 2017 18:16
by Jerry
Ok, I guess the rule to remember here is that the string matching proceeds from left to right with no overlapping. So the "Xx" matches the first XX, takes those 2 characters out of consideration for further matching and moves along. This is also the way Notepad does its case-insensitive search and replace too.
But it does seems surprising initially to see the string "Xx" appear in a name and find that the basic case-insensitive search and replace may not work on it, if that string does not appear in isolation from other "X's". Understandable, but surprising.
Case closed.