none
why doesn't this match RRS feed

  • Question

  • I have a thread here http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/5dbf8ce6-bfec-440c-946d-bddbc4f67430

    but this is a new question ... 

    So here it goes

    *****************************************************************************************************

     MatchCollection collection = Regex.Matches(strDocumentText, "<<<[a-zA-Z0-9]>>>");

     here is strDocumentText vairable  the string is html ( I put it in code block because then you can see more clearly)

    <HTML><HEAD>
    <META name=GENERATOR content="MSHTML 8.00.7600.16891"></HEAD>
    <BODY>
    <P>Dear <SPAN>&lt;&lt;&lt;Description&gt;&gt;&gt;</SPAN></P><!-- IM TRYING TO MATCH THIS -->
    <P><SPAN></SPAN>&nbsp;</P></BODY></HTML>

    Look at my comment , how will i match &lt;&lt;&lt;Description&gt;&gt;&gt; between the <SPAN> tags in regex

    NOTE THAT THE (Description) will always change

    So anything like &lt;&lt;&lt;[ANYTEXTBETWEEN]&gt;&gt;&gt;

    should be a match in the matchcollection.


    Thanks for any suggestions





    Sunday, November 13, 2011 9:36 AM

Answers

All replies

  • This &lt;&lt;&lt;\w+&gt;&gt;&gt; is working for me.
    Thanks,
    A.m.a.L Hashim
    Microsoft Most Valuable Professional
    Dot Net Goodies
    • Marked as answer by Magic Mushroom Sunday, November 13, 2011 10:15 AM
    Sunday, November 13, 2011 10:01 AM
  • > how will i match &lt;&lt;&lt;Description&gt;&gt;&gt; between the <SPAN> tags in regex
     
     
    using System.Text.RegularExpressions;
    ...
    var re = new Regex(
        @"dear\s*<.+?>(?<data>.+?)</.+?>",
        RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Compiled);
    var m = re.Match(html);
    if(m.Success)
    {
        var data = m.Groups["data"].Value;
        ...
    
     
      

    • Edited by Malobukv Sunday, November 13, 2011 10:03 AM
    Sunday, November 13, 2011 10:03 AM