How to copy marked text in notepad++
As of Notepad++ 5.9 they added a feature to 'Remove Unmarked Lines' which can be used to strip away everything that you don't want along with some search and replaces for the other text on each value line.
- Use the Search-->Find-->Mark functionality to mark each line you want to keep/copy and remember to tick 'Bookmark Line' before marking the text
- Select Search-->Bookmark-->Remove Unmarked Lines
- Use Search-->Find-->Replace to replace other text you do not want to keep/copy with nothing
- Save the remaining text or copy it.
You can also do a similar thing using Search-->Bookmark-->Copy Bookmarked Lines
So technically you still cannot copy marked text, but you can bookmark lines with marked text and then perform various operations on bookmarked or unmarked lines.
I am adding this for completeness as this post hits high in Google search results.
You can actually copy all from a regex search, just not in one step.
- Use Mark under Search and enter the regex in Find What.
- Select Bookmark Line and click Mark All.
- Click Search -> Bookmark -> Copy Bookmarked Lines.
- Paste into a new document.
- You may need to remove some unwanted text in the line that was not part of the regex with a search and replace.
Try this instead:
First, fix the line ending problem: (Notepad++ doesn't allow multi-line regular expressions)
Search [Extended Mode]: \r\n>
(Or your own system's line endings)
Replace: >
then
Search [Regex Mode]: <option[^>]+value="([^"]+)"[^>]*>.*
(if you want all occurences of value
rather than just the options, simple remove the leading option
)
Replace: \1
Explanation of the second regular expression:
<option[^>]+ Find a < followed by "option" followed by
at least one character which is not a >
value=" Find the string value="
([^"]+) Find one or more characters which are not a " and save them
to group \1
"[^>]*>.* Find a " followed by zero or more non-'>' characters
followed by a > followed by zero or more characters.
Yes, it's parsing HTML with a regex -- these warnings apply -- check the output carefully.
This is similar to https://superuser.com/questions/477628/export-all-regular-expression-matches-in-textpad-or-notepad-as-a-list.
I hope you are trying to extract :
"Performance"
"Maintenance"
"System Stability"
Here is the way - Step 1/3: Open Search->Find->Replace Tab , select Regular Expression Radio button. Enter in Find what : (\"[a-zA-Z0-9\s]+\") and in Replace with : \n\1 and click Replace All buttton.
Step 2/3: After first step your keywords will be in next lines.(as shown in next image). Now go to Mark tab and enter the same regex expression in Find what: Field. Put check mark on Bookmark Line. Then Click Mark All.
Step 3/3 : Goto Search -> Bookmarks -> Remove unmarked lines.
So you have the final result as below
It would be a great feature to have in Notepad++. I use the following technique to extract all the matches out of a file:
powershell
select-string -Path input.txt -Pattern "[0-9a-zA-Z ]*" -AllMatches | % { $_.Matches } | select-object Value > output.txt
And if you'd like only the distinct matches in a sorted list:
powershell
select-string -Path input.txt -Pattern "[0-9a-zA-Z ]" -AllMatches | % { $_.Matches } | select-object Value -unique | sort-object Value > output.txt