Community
    • Login

    Copy texts of one color

    Scheduled Pinned Locked Moved General Discussion
    9 Posts 5 Posters 339 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.
    • Iohiko ColinaI
      Iohiko Colina
      last edited by

      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
      • EkopalypseE
        Ekopalypse
        last edited by

        @Iohiko-Colina

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

        1 Reply Last reply Reply Quote 1
        • Anthony BlincoA
          Anthony Blinco
          last edited by Anthony Blinco

          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
          • Anthony BlincoA
            Anthony Blinco
            last edited by

            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

            Alan KilbornA 1 Reply Last reply Reply Quote 1
            • Alan KilbornA
              Alan Kilborn @Anthony Blinco
              last edited by

              @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
              • Anthony BlincoA
                Anthony Blinco
                last edited by Anthony Blinco

                Thanks Alan

                ^[\[\]\{\}]
                

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

                Alan KilbornA 1 Reply Last reply Reply Quote 0
                • Alan KilbornA
                  Alan Kilborn @Anthony Blinco
                  last edited by Alan Kilborn

                  @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
                  • guy038G
                    guy038
                    last edited by guy038

                    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
                    • Anthony BlincoA
                      Anthony Blinco
                      last edited by

                      Very nice! Well done

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