Reputation: 158
I am currently trying to convert an HTML-table like the following:
<table>
<tr>
<td>
Some Text
</td>
<td>
<img src="..." ...>
</td>
</tr>
...
</table>
Into an HTML-list like that:
<ul>
<li>
<div>
<p> Some Text </p>
</div>
<img src="..." ...>
</li>
...
</ul>
Since I need to do this in several files (100+) I would like to accomplish it using a regular expression. However, while I am able to catch the parts I am interessted in, it only seems to capture the last occurence of the capture groups.
Is there a way to get all captured parts back?
Here is my current progress:
<table>(?>\s*?<tr>\s*?<td>(.*?)<\/td>\s*?<td>.*?(<img[^>]*>).*?<\/td>.*?<\/tr>)+\s*?<\/table>
(If you are interrested, here is a link for fiddling around: https://regex101.com/r/hQ8pF1/2 )
My editor of choice is Sublime Text (using PCRE engine AFAIK), but I am willing to use anything to approach this task.
Upvotes: 2
Views: 64
Reputation: 371
Try using the TextCrawler tool (windows only AFAIK). It supports the regex search-and-replace for multiple files. Matching multiple occurences should be no problem.
And have you tried to match without the "table" around? like this https://regex101.com/r/hQ8pF1/3
Upvotes: 0
Reputation: 1625
\s*?<tr>\s*?<td>(.*?)<\/td>\s*?<td>.*?(<img[^>]*>).*?<\/td>.*?<\/tr>
w/ sig
for options should do it.
Upvotes: 2