Search and Replace: Ii/II doesn't work for IIi

Things you’d like to miss in the future...
Post Reply
Jerry
Posts: 805
Joined: 05 May 2010 15:48
Location: The UnUnited States of America

Search and Replace: Ii/II doesn't work for IIi

Post by Jerry »

[Using 21.80.0200]

Came across this unexpected behavior which I don't think is right, unless I am misunderstanding something.

1. Run xyplorer /fresh
2. Create file named "Aaa Iii Xxx"
3. Use Search and Replace to rename Ii/II. It works and you now have "AAa IIi Xxx".
4. Repeat step 3, and nothing changes. Why doesn't it change the remaining Ii to II ?

Same thing happens if you try search and replace Aa/AA or Xx/XX.
Running on Windows 10 Pro 64-bit quad-core ASUS G752-VY notebook with 64 GB RAM, over 26 external USB3 drives attached via multiple powered hubs with letters and mount points, totaling 120+ TB.

highend
Posts: 13317
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Search and Replace: Ii/II doesn't work for IIi

Post by highend »

At least I can confirm it. Don will (probably) fix it when he has time...
One of my scripts helped you out? Please donate via Paypal

admin
Site Admin
Posts: 60567
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Search and Replace: Ii/II doesn't work for IIi

Post by admin »

Use switch /c to make the comparison case sensitive: Ii/II /c

Jerry
Posts: 805
Joined: 05 May 2010 15:48
Location: The UnUnited States of America

Re: Search and Replace: Ii/II doesn't work for IIi

Post by Jerry »

admin wrote: 01 Jun 2021 12:23 Use switch /c to make the comparison case sensitive: Ii/II /c
Ok, that works for dealing with the second case. I assume you regard the inconsistency as undesirable.
Running on Windows 10 Pro 64-bit quad-core ASUS G752-VY notebook with 64 GB RAM, over 26 external USB3 drives attached via multiple powered hubs with letters and mount points, totaling 120+ TB.

admin
Site Admin
Posts: 60567
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Search and Replace: Ii/II doesn't work for IIi

Post by admin »

Certainly an interesting case. This will handle it in the next beta:

Code: Select all

    * File | Rename Special | Search and Replace...: If the replacement just 
      changes the CASE of the replaced string (eg: re/Re) then the matching is 
      now case-sensitive by default. You don't have to pass the /c switch for 
      case-sensitive matching.

admin
Site Admin
Posts: 60567
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Search and Replace: Ii/II doesn't work for IIi

Post by admin »

Well, I shot too fast. That "fix" would break old code and would also limit the functionality of Search and Replace.

What we have here might be undesirable but it's not an inconsistency but a logical outcome of case-insensitive matching and the standard replacement rules (which are not recursive = do not replace again what has been replaced). ATM I see no way to improve the situation. The /c switch is the way to go for you.

Jerry
Posts: 805
Joined: 05 May 2010 15:48
Location: The UnUnited States of America

Re: Search and Replace: Ii/II doesn't work for IIi

Post by Jerry »

admin wrote: 02 Jun 2021 08:08 What we have here might be undesirable but it's not an inconsistency but a logical outcome of case-insensitive matching and the standard replacement rules (which are not recursive = do not replace again what has been replaced). ATM I see no way to improve the situation. The /c switch is the way to go for you.
I understand the issue of recursive replacement; I would not expect the second replacement to take place while doing the first one. But in this example, there are 2 separately initiated, independent search/replace actions, each for a single replacement. The fact that the second replacement fails is clearly inconsistent. It makes one think that there is something special about doing the replacement when the pattern is followed by a space, but that surely shouldn't be the case.
Running on Windows 10 Pro 64-bit quad-core ASUS G752-VY notebook with 64 GB RAM, over 26 external USB3 drives attached via multiple powered hubs with letters and mount points, totaling 120+ TB.

admin
Site Admin
Posts: 60567
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Search and Replace: Ii/II doesn't work for IIi

Post by admin »

Nope, it has nothing to do with the space. Since your replace operation is case-insensitive in both cases the red pair of "ii" is replaced by "II". In the second run you don't note it because it is already "II":

"AAa IIi Xxx"

Jerry
Posts: 805
Joined: 05 May 2010 15:48
Location: The UnUnited States of America

Re: Search and Replace: Ii/II doesn't work for IIi

Post by Jerry »

admin wrote: 02 Jun 2021 14:23 Nope, it has nothing to do with the space. Since your replace operation is case-insensitive in both cases the red pair of "ii" is replaced by "II". In the second run you don't note it because it is already "II":
"AAa IIi Xxx"
So you are saying that since case sensitivity is off, the second independent search/replace action is matching and replacing "II" and not the remaining "Ii" so that in effect, there is no apparent change. Is that right?
Running on Windows 10 Pro 64-bit quad-core ASUS G752-VY notebook with 64 GB RAM, over 26 external USB3 drives attached via multiple powered hubs with letters and mount points, totaling 120+ TB.

admin
Site Admin
Posts: 60567
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Search and Replace: Ii/II doesn't work for IIi

Post by admin »

Yep

Post Reply