Case sensitive fix.
-
Hello guys! I am having a question: I have very long and multiple text files that have a lot of common strings inside of them.
Unfortunately, some of the strings are written with different case, and that is a no-no for my application.
I would like to know how can I make Notepad ++ (or any other program) run through these text files, find same strings that are written with different case (for example ‘String, string, sTriNg, STRING’ and so on,
and make all of these strings to be for, example “String”
(I should specify how exactly the string should look).
Thanx to all who are about to help me with their sugggestions. -
search the forum for the word Manchester in Posts only.
In this thread you will find a link to guy038s post regarding your issue.Cheers
Claudia -
HI thanx for the suggestion, I checked it out but this wont to the job,
I have to type each string manually and tell the pogram what string to replace it with.I am looking for something more automatic, that will take the 1st occurrence of the string, and replace all other (same )strings with the same 'capitalization" as the 1st string.
-
@dynamittt said:
(I should specify how exactly the string should look).
that’s why I suggested this solution but now you state
I am looking for something more automatic, that will take the 1st occurrence of the string,
How should this work, for example a text like this
Print line one but don't print the rest
If a script would find word Print it should replace next occurrence print?
Cheers
Claudia -
Hello , @dynamittt,
From your post, you would like to change a word, in any case by this same word, applying the Start case / Proper case capitalization rule. Refer to my other post, below, on the main Capitalization rules, for explanations :
https://notepad-plus-plus.org/community/topic/130/convert-case-to/4
Let’s suppose we start with the original sentence :
ThIs iS a pIeCe of TexT, tHAt neeDs tO Be noRMaliZEd !
- Then, the regex S/R : SEARCH
(\w)(\w*)
and REPLACE\u\1\L\2
would give the text ( Start case / Proper case ) :
This Is A Piece Of Text, That Needs To Be Normalized !
- On the opposite, the regex S/R : SEARCH
(\w)(\w*)
and REPLACE\l\1\U\2
would give the text ( First letter lowercase and others UPPERcase ) :
tHIS iS a pIECE oF tEXT, tHAT nEEDS tO bE nORMALIZED !
- For instance, the regex S/R : SEARCH
(\w)(?:(\w*)(\w))?
and REPLACE\u\1\L\2\u\3
would changed any outer letter UPPERcase and all other letters lowercase
ThiS IS A PiecE OF TexT, ThaT NeedS TO BE NormalizeD !
- Of course, the regex S/R SEARCH
(?-s).+
and REPLACE\U$0
would give the text, all UPPERcase :
THIS IS A PIECE OF TEXT, THAT NEEDS TO BE NORMALIZED !
- And the regex S/R SEARCH
(?-s).+
and REPLACE\L$0
would give the text, all lowercase :
this is a piece of text, that needs to be normalized !
Note : If you just want to apply the changes on a specific normal selection, click on the In selection option, of the Replace dialog
Now, if you just want to change any case, of a known word, in a specific case, simply use the following regex.
For instance, to change any occurrence, in any case, of the exact word Test, into the exact string tESt, use the regex S/R :
SEARCH
(?i)\btest\b
REPLACE
tESt
So the line :
TEST test Test tEST TesT
would be modified, as below :
tESt tESt tESt tESt tESt
Remarks :
-
For any S/R above, select the Regular expression search mode
-
You may use, either, the Replace All button or the Replace button
-
Preferably, use the In Selection option, in conjunction with the Replace All button
-
If the caret/cursor is located in the middle of a word, only the part of that first word, located on the right, will be changed, of course !
Best Regards,
guy038
- Then, the regex S/R : SEARCH
-
Thank you!