DONE: Case Sensitive Context Search and Replace

Make a request or discuss new features.
Post Reply
User avatar
rjbill
Posts: 830
Joined: 13 Jun 2011 06:36

DONE: Case Sensitive Context Search and Replace

Post by rjbill »

Since I know you don't have much to do and voluminous amounts of spare time,
I thought I would mention this feature. ;o)

It is pretty much a programmer's request.

I find that I often have the need to do Search and Replaces where the word
is the same, but there are multiple contexts of it where some are lowercase,
some are capitalized, and some are uppercase.

So you can't do a simple Search and Replace.

Basically you have to do three separate Search and Replaces, one for each "context",
or do one lowercase Replace and then manually correct those that need to be capitalized or uppercase.

Here is an example: (shown after the replace)

Code: Select all

<div class="sb_title"><img src="/images/random_authors.png"
   alt="Random Authors" title="Random Authors - Pulled from our Members' List" /></div>
For this line, I wanted to change "member" to "author" (except the one instance), and
there were two instances of "member", a lowercase and two capitalized.
This is a very simple example.

Sometimes there can be many, or dozens of instances, strewn throughout a program.

This usually involves variable names and related programming contexts. (like the example)

I don't know if it would be worth it or not to add functionality like this, but I would use it,
and it would save me some time. (and irritation, etc.)

Also, the names to change could be in "complex" formats, like changing "member_name" to
"author_name". (that is, "author_name", "Author_Name", and "AUTHOR_NAME")
It would be an interesting algorithm to program.

(I guess you would just have to look at the FOUND value and then make each letter
of the REPLACE value the same case to match -- I suppose the values would have to be
the same size (length) for it to work, otherwise it would be too complex to program,
although you could just match as many characters as match length-wise for those
instances, and any other more complex situations would just have to be done with
multiple Search and Replaces, but you would probably get 95% of the scenarios that way --
I was thinking something like "member" to "author_1", and "member_name" to "author_fullname", etc. --
with some "fancy programming" and logic, you could do some nice stuff, like looking
at the FOUND value and figuring out if it is all lowercase, has some capitalization or not,
and are there "word separators"? (so search and replace words could be of different lengths),
or all uppercase, etc...)

Maybe someday.
RJTE version 14.64 (actual) - 64-bit
Win 10 Pro 64-bit 8 GB RAM Intel Core i7-6700 3.40 GHz SCSI Hard Drive 1 TB

Note: The signature is dynamic, not static,
so it may not show the correct version above
that was in use at the time of the post.

crtrubshaw
Posts: 250
Joined: 06 Jun 2012 11:08

Re: Case Sensitive Context Search and Replace

Post by crtrubshaw »

Hi Rickard, I would also like to add a vote for this feature, just today I had a case where I needed to do this, in the end I changed by find text but a case-aware replace function would be awesome!

Thanks for your consideration :-D

User avatar
Rickard Johansson
Site Admin
Posts: 6000
Joined: 19 Jul 2006 14:29

Re: Case Sensitive Context Search and Replace

Post by Rickard Johansson »

Added in next release (version 13.60).

I added a search option called "Preserve Case". If checked - replace will try to replace a text and preserve the case. The length of the find and replace strings doesn't have to match.

Ex.
Find
member_name

Replace with
auth_fullname

Result

Code: Select all

member_name	=> auth_fullname
Member_Name	=> Auth_Fullname
MEMBER_NAME	=> AUTH_FULLNAME

User avatar
yereverluvinuncleber
Posts: 266
Joined: 20 Apr 2018 09:49

Re: DONE: Case Sensitive Context Search and Replace

Post by yereverluvinuncleber »

Very good. Look forward to testing.
"Noli pati a scelestis opprimi"... or is it "non lacessit illegitimae te carborundum"?

You can find me on Deviantart https://www.deviantart.com/yereverluvinuncleber/gallery/

User avatar
rjbill
Posts: 830
Joined: 13 Jun 2011 06:36

Re: DONE: Case Sensitive Context Search and Replace

Post by rjbill »

Nice. Thanks.
RJTE version 14.64 (actual) - 64-bit
Win 10 Pro 64-bit 8 GB RAM Intel Core i7-6700 3.40 GHz SCSI Hard Drive 1 TB

Note: The signature is dynamic, not static,
so it may not show the correct version above
that was in use at the time of the post.

Post Reply