• Login
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.
  • J
    JacksonSpike
    last edited by Jun 7, 2023, 4:36 PM

    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:

    P 1 Reply Last reply Jun 7, 2023, 6:02 PM Reply Quote 0
    • P
      PeterJones @JacksonSpike
      last edited by Jun 7, 2023, 6:02 PM

      @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
      • M
        Mark Olson
        last edited by Mark Olson Jun 7, 2023, 11:22 PM Jun 7, 2023, 10:59 PM

        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
        3 out of 3
        • First post
          3/3
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors