Page 1 of 1

Regex replace converts upper to lower case

Posted: Wed May 20, 2015 7:07 am
by etfb
This is an odd one. At first, I couldn't use backreferences in my regexes because I didn't know they're not supported by the search and replace dialog, only by the "quick find bar" or whatever it's called. A search of this forum helped me work that out, though I don't understand the reason for the limitation.

But then I did this. I have the following lines:

USER FRED
USER BARNEY
USER Wilma99

Using the quick find bar, I search for "USER ([A-Z0-9]+)" and replace with "u_\1". And I get this:

u_fred
u_barney
u_wilma99

It converts the backreferenced text to all-lowercase! Two questions:

1. WTF???
2. How do I make it stop?

Re: Regex replace converts upper to lower case

Posted: Wed May 20, 2015 7:09 am
by etfb
Hang on... just tried it again and it's working properly! It seems the "case sensitive match" button doesn't work immediately, but requires that you stop and restart the search. It's a very odd "feature", that...

Re: Regex replace converts upper to lower case

Posted: Wed May 20, 2015 9:52 am
by eranif
etfb wrote:This is an odd one. At first, I couldn't use backreferences in my regexes because I didn't know they're not supported by the search and replace dialog, only by the "quick find bar" or whatever it's called. A search of this forum helped me work that out, though I don't understand the reason for the limitation.
Simple: the quick-find-bar was developed _after_ the standard "Find and Replace" dialog with better capabilities.
etfb wrote:Hang on... just tried it again and it's working properly! It seems the "case sensitive match" button doesn't work immediately
It does. Its just that you dont see it immediately. When you click on the "Replace" button, it replaces the previous search (which was using a non-case search)
Now, when you click on the 'Case sensitive' button, it will affect the next 'Find' you click - this is why you think it does not affect immediately. IOW, when clicking on the 'Case sensitive' button it does not trigger a new search, instead it will be used on the next search

Eran