Page 1 of 1
Search and Replace: Ii/II doesn't work for IIi
Posted: 31 May 2021 14:33
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.
Re: Search and Replace: Ii/II doesn't work for IIi
Posted: 01 Jun 2021 11:55
by highend
At least I can confirm it. Don will (probably) fix it when he has time...
Re: Search and Replace: Ii/II doesn't work for IIi
Posted: 01 Jun 2021 12:23
by admin
Use switch /c to make the comparison case sensitive: Ii/II /c
Re: Search and Replace: Ii/II doesn't work for IIi
Posted: 01 Jun 2021 13:51
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.
Re: Search and Replace: Ii/II doesn't work for IIi
Posted: 01 Jun 2021 20:22
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.
Re: Search and Replace: Ii/II doesn't work for IIi
Posted: 02 Jun 2021 08:08
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.
Re: Search and Replace: Ii/II doesn't work for IIi
Posted: 02 Jun 2021 14:06
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.
Re: Search and Replace: Ii/II doesn't work for IIi
Posted: 02 Jun 2021 14:23
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"
Re: Search and Replace: Ii/II doesn't work for IIi
Posted: 02 Jun 2021 14:54
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?
Re: Search and Replace: Ii/II doesn't work for IIi
Posted: 02 Jun 2021 14:57
by admin
Yep