Help you! Sorry to attract everyone's attention...
This is now the case:
Code
String testInput = @ "asdfs <ul id = 'aas 'class = 'sdfsdfsadfs'> <li> Hello, everyone! </Li> <li> thank you! </Li> </ul> bbbb ";
Regex reg = new Regex (@"(? <Ul> <ul [\ s \ S] *? \> [\ S \ S] *? </Ul>) ", RegexOptions. Multiline | RegexOptions. IgnoreCase );
MatchCollection ML = reg. Matches (testInput );
Foreach (Match M in ML)
{
If (M. Success)
{
TextBox1.Text + = M. Groups ["ul"]. Value;
}
}
String testInput = @ "asdfs <ul id = 'aas 'class = 'sdfsdfsadfs'> <li> Hello, everyone! </Li> <li> thank you! </Li>
</Ul> bbbb ";
Regex reg = new Regex (@"(? <Ul> <ul [\ s \ S] *? \> [\ S \ S] *? </Ul>) ", RegexOptions. Multiline | RegexOptions. IgnoreCase );
MatchCollection ML = reg. Matches (testInput );
Foreach (Match M in ML)
{
If (M. Success)
{
This. TextBox1.Text + = M. Groups ["ul"]. Value;
}
}
String testInput = @ "<ul id = 'aas 'class = 'cc'>
<Li> Hello everyone </li>
<Li> please! </Li> </ul> ";
Regex reg = new Regex (@"(? <Ul> <ul [\ s \ S] *? \> [\ S \ S] *? </Ul>) ", RegexOptions. Multiline | RegexOptions. IgnoreCase );
MatchCollection ML = reg. Matches (webCode );
Foreach (Match M in ML)
{
If (M. Success)
{
Response. Write (M. Groups ["ul"]. Value + "<br/> ");
}
}
If the string is testInput, the matching is good.
You can get the expected result,
<Ul id = 'aas 'class = 'sdfsdfsadfs'>
<Li> Hello, everyone! </Li>
<Li> thank you! </Li>
</Ul>
However, if testInput is changed to the following:
Code
@ "Asdfs <ul id = 'aas 'class = 'sdfsdfsadfs'>
<Li> Hello, everyone! </Li>
<Li> <ul id = 'cdd'> <li> experts, I am an interference expert </li> <li>, I am interfering with matching </li> </ul> </li>
<Li> thank you! </Li>
</Ul> bbbb ";
The result I got is
<Ul id = 'aas 'class = 'sdfsdfsadfs'>
<Li> Hello, everyone! </Li>
<Li> <ul id = 'cdd'> <li> experts, I am an interference expert </li> <li>, I am interfering with matching </li> </ul>
The expected result is:
Code
<Ul id = 'aas 'class = 'sdfsdfsadfs'>
<Li> Hello, everyone! </Li>
<Li> <ul id = 'cdd'> <li> experts, I am an interference expert </li> <li>, I am interfering with matching </li> </ul> </li>
<Li> thank you! </Li>
</Ul>
Contains a complete ul nesting,
Ladies and gentlemen, let's take a look at how to write this regular expression. Thank you.