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:
<option value="Performance"
>Performance</option>
<option value="Maintenance"
>Maintenance</option>
<option value="System Stability"
>System Stability</option>
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?
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.