Copy texts of one color



  • 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



  • @Iohiko-Colina

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



    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



  • 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



  • @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:

    ^[[]\{\}]
    


  • Thanks Alan

    ^[[]\{\}]
    

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



  • @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. :-)

    ^[\[\]\{\}]
    


  • 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



  • Very nice! Well done


Log in to reply