4

I am looking for a simple way to copy into the clipboard all the "marks" in notepad++.

I found that I could copy the whole line that match the regex using the bookmark option. But I'm looking for a way to copy only the marked text (or the text that matches the regex expression).

The ideal would be to past the output separated by newline (or custom separator).

I looked into TxtFX option without luck. I looked into the plugin/python script lib, is there inside any of those code that could copy the marked text into the clipboard ?

In brief, is there a way to makes it -in one shot- using notepad++?

(I've seen I could do it using SynWrite -using command "Extract strings"- but using notepad++ would be better).

7
  • As-is, your question is a little confusing, what do you mean by "Marks"? Can you provide some example data, an example result and the RegEx you've tried using? Why not just perform a RegEx Find and then Ctrl-C to copy the found, matching text? Do you know about RegEx "capture groups" for find and replace? Oct 3, 2014 at 15:28
  • after entering my Regex '(?<=#)\w+' I'm using the "mark" tab on the ctrl+F windows in notepad++.
    – JinSnow
    Oct 3, 2014 at 15:33
  • Why not just perform a RegEx Find and then Ctrl-C to copy the found, matching text? Unfortunately it doesn't work. What am I doing wrong : I enter the the regex in the find windows, then "find all in the current document" then CTRL+C?
    – JinSnow
    Oct 3, 2014 at 15:37
  • Do you know about RegEx "capture groups" for find and replace? No, I'm goggling it.
    – JinSnow
    Oct 3, 2014 at 15:40
  • Could you provide some sample text? I ask because I think one option may be "inverting" your regex to catch everything but what you want copied. Then you could replace the match to leave yourself with only what you want.
    – Excellll
    Oct 3, 2014 at 15:41

1 Answer 1

2

I also couldn't find a way to select and copy every marked match. I'm a fairly novice NP++ user though, so maybe someone else knows how to do this.

However, you could instead search for everything you don't want to copy and replace it with nothing. This will leave you with only what you want, so you can copy it or use it as you like. Then just be sure to undo, save the result as a new file, or don't save at all in order to keep your original data intact.

Based on your comments, you're trying to grab hashtags from some text. You can use the following regex pattern to match everything but hashtags:

(?<!#)\b[^#]+

Replace all with nothing or a space.

Explanation of pattern:

\b[^#]+ maximally matches text, starting from a word boundary, that does not include a pound sign.
(?<!#) is a negative look-behind for the pound sign. This prevents matching any text immediately preceded by a pound sign.

This should leave nothing but hashtags behind. [^#]+ seems to be matching newline characters as well, so this will leave all your hashtags on a single line.

1
  • Thank you very much Excelll your trick and your great explainations! It does works perfectly! I'll let the question open to find a way that could work in all case (something like "copy all the regex results").
    – JinSnow
    Oct 4, 2014 at 15:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .