Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular expression for Notepad++

Long story short, I have a very large table (1200+ rows) from a custom Excel to html conversion, which is working beautifully, except for a final missing part. I'm no good with RegEx, and I think I need it for a Find and Replace in Notepad++. Below is what I have and what I need.

Input:

<td>image1</td>
<td>image2</td>
...
<td>image1242</td>

Needed output:

<td><img src="image1.png" alt="" /></td>
<td><img src="image2.png" alt="" /></td>
...
<td><img src="image1242.png" alt="" /></td>

Please advice!

like image 747
user1640453 Avatar asked Jul 13 '26 06:07

user1640453


2 Answers

Use this regular expression:

<td>image(.+)</td>

and the following pattern as a replacement:

<td><img src="image\1.png" alt"" /></td>

As a sidenote, it is usually not a good practice to parse HTML with regular expressions - in simple cases like this, it might be sufficient, but for anything more complicated, it would be much better to parse the HTML like XML file.

If you know some C#, you could use HTML Agility Pack for that.

like image 196
Nikola Anusev Avatar answered Jul 15 '26 06:07

Nikola Anusev


Do this way:-

Find What:

<td>image(\d+)</td>

Replace With:

<td><img src="image\1.png" alt="" /></td>

Refer the screenshot:

Find Replace with Regex

like image 26
Siva Charan Avatar answered Jul 15 '26 05:07

Siva Charan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!