I am trying to parse some reStructuredTex开发者_如何学编程t and want to be able to identify when the indent level has changed. So, I need to be able to see when an indent of 8 spaces has changed to an indent of 4 spaces (for example), so that I can change the color of that text block. Is there a way of using regular expressions to count the number of spaces in the indent and pick out the next line that contains a shallower indent?
Something like this will work:
/
^(\s*)\S.*$    #Find a line with some number of spaces
(?:^\1\S.*$)*  #Find more lines with the same starting spaces
^.*$           #This is the line you want here
/xm            #x to ignore whitespace in the regex.
               #m to have ^and $ match all lines
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论