3

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!

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

2 Answers2

2

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.

Community
  • 1
  • 1
Nikola Anusev
  • 6,940
  • 1
  • 30
  • 46
1

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

Siva Charan
  • 17,940
  • 9
  • 60
  • 95