Community
    • Login

    Possible to Change Case using Search/Replace or Other

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 3 Posters 284 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Dennis SchroederD
      Dennis Schroeder
      last edited by

      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: A

      I’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!

      CoisesC Mark OlsonM 2 Replies Last reply Reply Quote 1
      • CoisesC
        Coises @Dennis Schroeder
        last edited by

        This post is deleted!
        1 Reply Last reply Reply Quote 1
        • Mark OlsonM
          Mark Olson @Dennis Schroeder
          last edited by Mark Olson

          @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>
          
          1 Reply Last reply Reply Quote 3
          • Dennis SchroederD
            Dennis Schroeder
            last edited by

            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.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors