I am not very well-versed in regular expressions, but I am trying to accomplish something in ASP.Net which I think requires them.
I am pulling in an HTML file, doing some processing, and outputting new "merged" html. The portion I am struggling with is grabbing a chunk of code located between two predefined "tags" of my own creation.
Here is an example of the relevant input html:
<table style="width: 500px; font-family: Trebuchet MS, sans-serif; font-size: 13px; background-color: #fff; border: 0; border-collapse: collapse;" align="center" cellspacing="0">
<thead>
<tr>
<th colspan="3" style="text-align: left;border-bottom: 1px solid #DDDDDD;">
Add-ons
</th>
</tr>
</thead>
<tbody>
[AddonsListSTART]
<tr style="border-bottom: 1px dashed #DDDDDD;">
<td>[AddonName]</td>
<td>[AddonQty]</td>
<td align="right">[AddOnPrice]</td>
</tr>
[AddonsListEND]
</tbody>
</table>
<br />
This is my C# code:
//Find Add-ons HTML : between [AddonsListSTART] & [AddonsListEND]
Regex rgxAddonSE = new Regex(@"\[AddonsListSTART\](?<MyHtml>.*)\[AddonsListEND\]");
Match matchAddonSE = rgxAddonSE.Match(htmlEmail);
string htmlAddons = matchAddonSE.ToString();
What I want to happen is for "htmlAddons" to be equal to the string:
<tr style="border-bottom: 1px dashed #DDDDDD;">
<td>[AddonName]</td>
<td>[AddonQty]</td>
<td align="right">[AddOnPrice]</td>
</tr>
The problem is that it is always blank, and "matchAddonSE.Success" is always FALSE. I know there is something wrong with my regex, but I can't figure out what.
Thank you in advance for any help.
Heather