• Login
Community
  • Login

Copy texts of one color

Scheduled Pinned Locked Moved General Discussion
9 Posts 5 Posters 346 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.
  • I
    Iohiko Colina
    last edited by Jun 1, 2021, 6:32 PM

    hi, is there any way to copy only the words in quotes that are in red color in this file?

    Link: https://www.mediafire.com/file/gqnych03fdr2xhc/governments.7z/file

    Password: galimulator

    Example:

    42310240-3f48-4c78-b42c-231ae7f12135-image.png

    1 Reply Last reply Reply Quote 0
    • E
      Ekopalypse
      last edited by Jun 1, 2021, 9:39 PM

      @Iohiko-Colina

      I don’t see how this can be accomplished without using a scripting plugin.

      1 Reply Last reply Reply Quote 1
      • A
        Anthony Blinco
        last edited by Anthony Blinco Jun 2, 2021, 2:45 AM Jun 2, 2021, 2:42 AM

        1. Make a copy of your file
        2. Replace using regular expression find=.*": replace=nothing
        3. Edit/Line operations/Trim leading and trailing space
        4. find=^[\\]\{\}] replace=nothing
        5. find=\,$ replace=nothing
        6. Edit/Line operations/Remove Empty lines

        This should leave you with a file containing the quoted red text

        1 Reply Last reply Reply Quote 2
        • A
          Anthony Blinco
          last edited by Jun 2, 2021, 2:48 AM

          My search string was incorrect It should be
          Caret Open-square-bracket Backslash Open-square-bracket Backslash Close-square-bracket Backslash Open-curley-bracket Backslash Close-curley-bracket Close-square-bracket

          A 1 Reply Last reply Jun 2, 2021, 11:51 AM Reply Quote 1
          • A
            Alan Kilborn @Anthony Blinco
            last edited by Jun 2, 2021, 11:51 AM

            @Anthony-Blinco said in Copy texts of one color:

            Caret Open-square-bracket Backslash Open-square-bracket Backslash Close-square-bracket Backslash Open-curley-bracket Backslash Close-curley-bracket Close-square-bracket

            LOL. That’s a lot of effort to go to.

            Try typing your string here just as you want it to be, and then select its text and press the </> button in the toolbar, this yellow “button”:

            Imgur

            If I do it with your text I obtain this result:

            ^[\[\]\{\}]
            
            1 Reply Last reply Reply Quote 0
            • A
              Anthony Blinco
              last edited by Anthony Blinco Jun 2, 2021, 7:31 PM Jun 2, 2021, 7:28 PM

              Thanks Alan

              ^[\[\]\{\}]
              

              Still drops the backslash before the second and third square bracket (Looks ok in preview though)
              preview.png

              A 1 Reply Last reply Jun 2, 2021, 7:32 PM Reply Quote 0
              • A
                Alan Kilborn @Anthony Blinco
                last edited by Alan Kilborn Jun 2, 2021, 7:33 PM Jun 2, 2021, 7:32 PM

                @Anthony-Blinco said in Copy texts of one color:

                Still drops the backslash before the second and third square bracket

                Oh, yea, that’s a bug in this site.
                On those you have to double the backslash, which causes it NOT to look right in the preview, but to post correctly.
                If you actually post, and then it looks wrong, edit it before the 3 minute timeout and add backslashes until it looks right. :-)

                ^[\\[\\]\{\}]
                
                1 Reply Last reply Reply Quote 2
                • G
                  guy038
                  last edited by guy038 Jun 2, 2021, 8:12 PM Jun 2, 2021, 7:44 PM

                  Hello, @iohiko-colina, @ekopalypse, @anthony-blinco, @alan-kilborn and All,

                  No problem with regexes ! It’s the @anthony-blinco’s regex attempt which gave me the idea to simplify the overall process :

                  I assume that your N++ version is, at least, 7.9.1

                  • Open the Mark dialog ( Ctrl + M )

                  • MARK (?-s)^(?:.+?:)?\h+\K"[^:]+?"(?=,?$)

                  • Tick the Purge for each search and Wrap around options

                  • Un-tick all other box options

                  • Select the Regular expression search mode

                  • Click on the Mark All option ( With your provided JSON sample, it highlights 400 occurrences in red ! )

                  • Click on the Copy Marked Text button

                  • Open a new tab ( Ctrl + N )

                  • Paste the contents of the clipboard ( Ctrl + V )

                  Here we are !

                  Remark : If you prefer to get the different strings without the double-quotes ("), use that second regex :

                  • MARK (?-s)^(.+?:)?\h+"\K[^:]+?(?=",?$)

                  Notes :

                  • The first regex contains an optional non-capturing group (?:.+?:)?. So the overall regex can be decomposed into two regexes :

                    • The regex (?-s)^\h+\K"[^:]+?"(?=,?$) which matches all strings contained in a "level-#": [•••••] block**

                    • The regex (?-s)^.+?:\h+\K"[^:]+?"(?=,?$) which matches the second string of lines beginning with blank chars and a first "xxxxx": string

                  Best Regards,

                  guy038

                  1 Reply Last reply Reply Quote 2
                  • A
                    Anthony Blinco
                    last edited by Jun 2, 2021, 8:10 PM

                    Very nice! Well done

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