I have a source code and want simply to copy the strings which I find with an regular expression.
Just like:
asdladhsfhjk-hello1-asdlkajhsd asdsa-hello3-asdhjkl asdölkj-hello5-
that I simply want to copy the -helloX- from the text. And not the line..
How do I do it?
After the Find In Files, your results window will have some number of lines. If you click on a single line and either RClick > Copy will copy just that single line. If you click on the line that says a file name, then the RClick > Copy action will copy the results from that file.
1 Answer. Show activity on this post. Total 2 lines were bookmarked. now go to "search" menu > bookmark > copy bookmarked line.
Using Regex to find and replace text in Notepad++ In all examples, use select Find and Replace (Ctrl + H) to replace all the matches with the desired string or (no string). And also ensure the 'Regular expression' radio button is set.
[update: see extended instructions below if you are working with a file that has 1. lines with and lines without the pattern and 2. you want to erase all lines without the pattern and 3. only preserve the pattern from the remaining lines ].
Do a regular expression Find and Replace, with the search pattern as ^.*?(-hello[0-9]+-).*$
and the replacement as \1
.
^.*?
.()
, so that it can be captured in a capture group..*$
.\1
is the contents of the capture group matched in the ()
s.Here's how to delete non-pattern lines and preserve only the patterns from lines with the pattern.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With