Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 707803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:19:09+00:00 2026-05-14T04:19:09+00:00

This is a related to a previous question I have asked here, see the

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T04:19:09+00:00Added an answer on May 14, 2026 at 4:19 am

    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:

    Dim ulCounter As Integer = 0    
    Dim rxUL As New Regex("<ul>|</ul>")
    
    xmlValue = rxUL.Replace(xmlValue, AddressOf Convert_UL)
    
    
    Protected Function Convert_UL(ByVal m As Match) As String
    
        Dim HTML As String = ""
    
        If m.Value = "</ul>" Then
            ulCounter -= 1
    
            HTML = "</textformat>"
        Else
            ulCounter += 1
    
            If ulCounter > 1 Then
                HTML = "<textformat indent=""20"">"
            Else
                HTML = "<textformat indent=""0"">"
            End If
        End If
    
        Return HTML
    
    End Function
    

    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!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is related to a previous question I asked with Jquery. If I have
This is closely related to a previous question i asked. I have a many-to-many
This is related to my previous question , but a different one. I have
This question is related to my previous question . The storyline: I have an
This is kind of related to my previous question, but not really. I have
This is related to my previous question here . I want 4 divs (absolute
This question is related to a previous question I asked, but it's a different.
This is related to a previous question . What I'm trying to understand now
Here's a link to my previous related question . -------------- | ServiceA.svc | ------------>
This is related to my previous question , but it seems I have another

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.