Community
    • Login

    Selecting things of a certain type

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 3 Posters 8.3k 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.
    • JacksonSpikeJ
      JacksonSpike
      last edited by

      Hi, I was wondering whether I could select things that the application sees as separate things. I’m very new to Notepad++. I was editing a minecraft language file and I want an easy way to select all the strings so I can change them to uppercase all at once. Please help. Thanks!innit bruv.png
      Here’s the file I was working on:

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @JacksonSpike
        last edited by

        @JacksonSpike ,

        Your use of the phrases “certain type” or “separate things” is rather ambiguous.

        If you have a selection in Notepad++, then Edit > Convert Case To… > UPPERCASE (or the Ctrl+Shift+U default keyboard shortcut) will convert the active selection to all-caps.

        For manually selecting multiple pieces of text at the same time, Settings > Preferences > Editing > ☑ Enable Multi-Editing will allow you to use Ctrl+Click (and drag) to select multiple pieces of text at the same time.

        Or, if you have a search expression (in Regular Expression mode) that can find all the text that you want to uppercase, if your Find What already finds the right text, then Replace With can be set to \U$0 to replace the found text with the uppercase version of the text.

        But without more detail than you gave, I can only give this hints.

        ----

        (The links above were taken from various sections of the Online User Manual)

        Useful References

        • Please Read Before Posting
        • Template for Search/Replace Questions
        • Formatting Forum Posts
        • Notepad++ Online User Manual: Searching/Regex
        • FAQ: Where to find other regular expressions (regex) documentation
        1 Reply Last reply Reply Quote 1
        • Mark OlsonM
          Mark Olson
          last edited by Mark Olson

          Find/replace (?-si)(?::\s*"|(?<!%)%\d*[dsf]|(?!\A)\G)\K((?:(?!(?:(?<!%)%\d*[dsf]|")).)*) with \U\1\E.

          Note that this won’t actually convert all your text to upper-case, because some of it (the %s format specifiers) will probably cause bugs downstream if it is capitalized. This regex is very careful to avoid capitalizing format specifiers, which is a lot of why it looks (and is, TBH) so hairy.

          My regex doesn’t handle all the possible syntax surrounding format specifiers, because I don’t have 3 hours to spend enumerating and debugging each weird edge case, but it should be fine assuming that all the strings are values in dictionaries. The find-regex becomes the absolutely abhorrent (?-si)(?:"|(?<!%)%\d*[dsf]|(?!\A)\G)\K(?=[^"]*"\s*[,\]\}])((?:(?!(?:(?<!%)%\d*[dsf]|")).)*) in the case where the strings can be strings in arrays or values in dictionaries.

          Test text:

          {
              "a.b": "caps %02d %5s %d %03fnocaps %%02dcaps",
              "b.c.d": "%%caps %3sap %s cap"
          }
          

          Expected output:

          {
              "a.b": "CAPS %02d %5s %d %03fNOCAPS %%02DCAPS",
              "B.C.D": "%%CAPS %3sAP %s CAP"
          }
          

          If you’re absolutely sure you want to capitalize everything that’s not a key, just use this much simpler regex-replace: "\s*:\s*"[^"]*"

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