Thursday, April 28, 2011

ASP.net REGEX Question: Find specific match, then skip everything to end tag

strRegex = New StringBuilder
strRegex.Append("<td class=""[\s\w\W]*?"">(?<strTKOWins>[^<]+)[\s]*?<span  
                 class='[\s\w\W]*?'>(T)KOs[\s\w\W]*?</span>[\s\S]*</td>")
                Regex = New System.Text.RegularExpressions.Regex(strRegex.ToString, 
                RegexOptions.None)
Matches = Regex.Match(results, strRegex.ToString)

This is my code. I want to match:

[? what ? Please insert here what you want to match]

The problem is that after the end of the SPAN tag, I want to skip everything inside the Table Cell and skip all the way to the end tag </td>

How can I do that?

From stackoverflow
  • i have no idea what you are trying to do. but this regex will find a tablecell, with a span inside of it then go to its corresponding closing tag. fill in all the specifics you need to and change it how you need to....

    for eg,

    text:

    <td class="td class"> anything at all in here?! <span class="span class">span text</span>text in the tablecell?</td>
    

    regex:

    <td\s+class=".*?">.*?<span\s+class=".*?">.*?</span>.*?</td>
    

    no idea what all this "strTKOWins" crap is or whether you want specific stuff in your span found?

    (T)KOs[\s\w\W]*?
    

    guess i cant really help until you respond anyways....

0 comments:

Post a Comment