I have a very long HTML Code with the following structure:
<td class="tar">
<div class="bubble in">
Some Text, I want to keep! And maybe even an image.<br />
<span class="time"><div style="text-align:right">17:14</span></div>
</div>
</td>
</tr>
<tr>
<td class="tal">
<div class="bubble out">
Some Text, I want to keep! And maybe even an image.<br />
<span class="time"><div style="text-align:right">17:15</span></div>
</div>
</td>
</tr>
This is the structure of a chat with the two participants "bubble in" and "bubble out". As you can see every "block" (Chat-Message) has a timecode like "17:14". I want to extend this timecode with a space character and an image but only for the text-block coming from "bubble in".
I am trying to accomplish this with the find & replace feature in Notepad++.
Here is what I came up with:
Find what:
<div class="bubble in">[^"]*<span class="time"><div style="text-align:right">([0-9]*[0-9]*):([0-9]*[0-9]*)</span></div>
Replace with:
<div class="bubble in">\1<span class="time"><div style="text-align:right">\2\3\4\5\6 <img src= "test.png" width="16" height="10" alt="0"/</span></div>
The searching works but replacing \\1 doesn't work somehow. Can you help me out? I am new to RedEx and figured this out by searching the internet and just trying. I think I am pretty close but only the wildcard [^"] for the random text is not yet correct.
You can try with:
Find what:
(<div class="bubble in">.*?<span class="time"><div style="text-align:right">[0-9]{1,2}:[0-9]{1,2})(</span></div>)
Replace with:
\1 <img src= "test.png" width="16" height="10" alt="0"/> \2
Can you explain what you are trying to use \\1 for? Each backslash number corresponds to a capture group, which is the pattern enclosed in ( ) in your search pattern. You only have 2 capture groups, but you are referencing 6 unique groups when you go up to \\6. If you posted the output of the substitution, that could be helpful. Also using a site like regex101.com can help you debug your regex.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.