Possible to Change Case using Search/Replace or Other
-
I’ve got an XML file that is being exported with mixed case data. It needs to be imported into a new system where all of the data is UPPER CASE, and it won’t properly import if the cases don’t match. This would be so easy if Excel could open the XML, edit it, then save it back in the same format…but apparently it doesn’t do that.
I’m wondering if I can somehow use the SEARCH/REPLACE with a regular expression to accomplish this, even if I need to do it letter by letter (a to A, b to B, etc).
I’m BRAND NEW to Notepad++. I discovered the lookbehind and lookahead functions in a sample, but haven’t been able to figure out how to get those to select a single character for replacement.
Sample:
<test>ChristmasTime</test>Desired Result:
<test>CHRISTMASTIME</test>I want to do this without touching any of the XML <???> data, as changing the case of these could also break the import.
My lame attempt to select the letter “a” for selection:
Find what: (?<=>)a(?=<)
Replace with: AI’m not sure there is a way to do this. I found a reply discussing this function and it seems to want a fixed number of characters, or “everything between > and <” in my case. Maybe there is another function that would help?
Thanks in advance for any helpful suggestions!
-
This post is deleted! -
@Dennis-Schroeder
Assuming you don’t want to change the tags or the attributes, here’s a reasonable regex-replace:
Find what:<[^<>]+>(*SKIP)(*FAIL)|[^<>]+
Replace with:\U${0}\E
This is a great example of how backtracking control verbs make life way easier.
Test input:
<foo> text to change <bar baz="quz" blarten="zut"> this text should be uppercase <baz quz="fjfjjf">more text to change</baz> change this! </bar> <bar baz="but this is an attribute, so ignore this" duden="blah blah blah" >more text to make uppercase</bar> and yet more text to make uppercase </foo>
Test output:
<foo> TEXT TO CHANGE <bar baz="quz" blarten="zut"> THIS TEXT SHOULD BE UPPERCASE <baz quz="fjfjjf">MORE TEXT TO CHANGE</baz> CHANGE THIS! </bar> <bar baz="but this is an attribute, so ignore this" duden="blah blah blah" >MORE TEXT TO MAKE UPPERCASE</bar> AND YET MORE TEXT TO MAKE UPPERCASE </foo>
-
Mark…THANK YOU!!! I checked this is my quick sample and it worked perfectly. I will test it in the live export file on Monday.