Extract text between quotes and insert after tag
I am a regex noobie and can't seem to wrap my head around it. Thing is, I don't have time as I am on the clock and need to do other things. I would love a straight answer with an explanation of how it works (if possible).
What I have:
<li id=\"B1031.001\"><a href=\"#\">Bolted shear tab gravity connections</a></li>
What I need:
<li id=\"B1031.001\"><a href=\"#\">B1031.001 - Bolted shear tab gravity connections</a></li>
Basically, I need to take the value of the 'id' attribute and prepend it do the a tag's text. I am hoping there is a way to do this in Notepad++ with regex to make the process faster.
Thank you for reading, Patrick
You can do this:
search: <li id=\\"([^"]+)\\"><a href=\\"#\\">\K replace: $1 - (<- there is a trailing space)
\K removes all that has been matched on the left from the match result. In other words, all that has been matched on the left is not replaced. The only thing that is replaced is the empty string after the > (from the a tag). (The goal of the search pattern is only to capture the id value and to reach the insert position.)
([^"]+) captures the content of the id attribute in group 1. ([^"] all that is not a double quote, + one or more times)
$1 refers to the content of this capture group.