3

I have been struggling with this regex for while. I'm trying to transfer some HTML to mark down.

I have this code:

`"<ol>
   <li>This is a new list</li>
   <ol>
       <li>Embedded List</li>
       <li>Embedded List</li>
   </ol>
 </ol>"`

I need to add 4 space to all the <li> that are within two <ol> So just the second to <li> elements need the 4 spaces.

The regex in pseudo code would be find all <li> preceded by "<ol> any characters and <ol>.

This is what I tried so far (?<=\"<ol>\r\n)(?<=[A-Za-z]<ol>\r\n)<li> but no luck. Is this even possible using regex?

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
  • @WashingtonGuedes: If you think so, I posted it as an answer. – Wiktor Stribiżew Aug 20 '15 at 12:28