I have a part of HTML source file that contains strings that I want to select and copy at once, using the regex functionality of Notepad++.
Here is a part of the text source:
I'm using the regex "[0-9a-zA-Z ]*" to search the "value" values. I have also selected the feature in Notepad++ search to highlight/mark the found text. This working fine I now want to copy or cut only the highlighted text to clipboard for further processing. But I'm not able to find this functionality in Notepad++. Is this simply not possible or am I too dumb?
回答1:
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]:[^>
(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:
[^>
Yes, it's parsing HTML with a regex -- these warnings apply -- check the output carefully.
回答2:
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.
回答3:
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.
No, as of Notepad++ 5.6.2, this doesn't seem to be possible. Although column selection (Alt+Selection) is possible, multiple selections are obviously not implemented and thus also not supported by the search function.
回答6:
I had the same problem. You can list the regex matches in a new tab, every match in new line in PSPad Editor, which is very similar as Notepad++.
Hit Ctrl + F to search, check the regexp opion, put the regexp and click on List.
回答7:
It's not possible with Notepad but HERE'S THE EASY SOLUTION:
I resorted to another piece of free software: Expresso by Ultrapico.
Once installed go in the tab "Test Mode".
Copy your REGEX into the "Regular expressions" pane.
Paste your whole text to be searched into the "Sample text" pane of Expresso,
Press the "Run match" button. Right click in the "Search results pane" and "Export to..." or "Copy matched text to clipboard".
N.B.: The original author is @Andreas Jansson but it is hidden in a comment, so since this page is high ranked in Google Search I leave it here for others.
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.