This is a related to a previous question I have asked here, see the link below for a brief description as to why I am trying to do this.
Regular expression from font to span (size and colour) and back (VB.NET)
Basically I need a regex replace function (or if this can be done in pure VB then that’s fine) to convert all ul tags in a string to textindent tags, with a different attribute value for the first textindent tag.
For example:
<ul>
<li>This is some text</li>
<li>This is some more text</li>
<li>
<ul>
<li>This is some indented text</li>
<li>This is some more text</li>
</ul>
</li>
<li>More text!</li>
<li>
<ul>
<li>This is some indented text</li>
<li>This is some more text</li>
</ul>
</li>
<li>More text!</li>
</ul>
<ul>
<li>Another list item</li>
<li>
<ul>
<li>Another nested list item</li>
</ul>
</li>
</ul>
Will become:
<textformat indent="0">
<li>This is some text</li>
<li>This is some more text</li>
<li>
<textformat indent="20">
<li>This is some indented text</li>
<li>This is some more text</li>
</textformat>
</li>
<li>More text!</li>
<li>
<textformat indent="20">
<li>This is some indented text</li>
<li>This is some more text</li>
</textformat>
</li>
<li>More text!</li>
</textformat>
<textformat indent="0">
<li>Another list item</li>
<li>
<textformat indent="20">
<li>Another nested list item</li>
</textformat>
</li>
</textformat>
Basically I want the first ul tag to have no indenting, but all nested ul tags to have an indent of 20.
I appreciate this is a strange request but hopefully that makes sense, please let me know if you have any questions.
Thanks in advance.
Thanks for your help with this, I have managed to work out a solution myself using your reply.
Basically I am using a counter to keep track of what level of ul tag the regex has found, and then replacing it with the relevant attribute:
This was a pretty random request so I’m not sure how much help this would be to anyone else, but just in case that was how I got round it!