I want to get a way to get all the content between one open span tag and a close tag. The problem is that someday I can have a nested range, and I want to be sure that my regular expression does not stop the first ending interval that it sees.
To see my problem, look at this: Regex101: nested range
I want to be sure that I get everything between the open and close tags. no matter how much </span> I can find inside.
I found a library made by Stephen Levitan that could achieve my desires. The problem is that the example is basic, and I'm not sure that I can achieve what I want.
I am using the XregExp.matchRecursive method. In this example, they give a start tag and an end tag. My start tag is a bit complicated, it looks like this: <span style=\\?"color:([a-zA-Z\s]*?)\\?"> . The problem is that when I execute this method with this separator, I get this error: the line contains unbalanced separators . Checked string:
<p style=\"text-align:justify\"> <span style=\"font-size:12pt\"> <span style=\"color:Green\"> <span style=\"font-family:Verdana\">There is some content for a mm advertisment.There is some co</span> <span style=\"font-family:Times New Roman\">ntent for a mm advertisment.</span> </span> </span> </p>
I think my problem is with the regex, which I use as a start delimiter. As explain in the doc , we need to add a backslash dump level in the regular expression. Therefore, I am trying to use this regular expression as a start delimiter: <span style=\\\\?"color:([a-zA-Z\\s]*?)\\\\?"> . Still not working. I donβt see how I can do this to find this method, to find everything between a range that has a color style attribute and its close tag.
Maybe someone has a solution?
source share