1

This is my code:

private static Regex paginationRegex = new Regex("<div class=\"pagination\">.*?<ul>(?<lis>.*?)</ul></div>",
                            RegexOptions.Singleline | RegexOptions.IgnoreCase);

        static void Main(string[] args)
        {
            string output = File.ReadAllText("output.html");

            var match = paginationRegex.Match(output);

            var lis = match.Groups["lis"].Value;

        }

and this is my HTML in output.html:

<div class="pagination">
        <ul>
                <li><a href="javascript:searchPage('1')" class="arrowDeactiveLeftFirst"> </a></li>  
                            <li><a href="javascript:searchPage('1')" class="deActivateleftArrow"> </a></li>
                    <li>
                                    <a class="current" href="javascript:searchPage('1')">1</a>
                                </li>
          <li>
                                    <a href="javascript:searchPage('2')">2</a> 
                                </li>
          <li>
                                    <a href="javascript:searchPage('3')">3</a> 
                                </li>
                      <li><a href="javascript:searchPage('2')" class="rightArrow"> </a></li>
                          <li><a href="javascript:searchPage('730')" class="arrowRightLast"> </a></li>
              </ul>
      </div>

However the lis group is always empty. What am I missing?

Jack
  • 7,433
  • 22
  • 63
  • 107
  • 1
    he means var lis @AndrewWhitaker – Neel May 15 '14 at 11:00
  • 1
    @Neel: Right, I understand that `var lis` is empty, but the Regex is looking for a tag named ``. I'm asking if this should be `
  • ` instead.
  • – Andrew Whitaker May 15 '14 at 11:06
  • 2
    @Andrew and Charlie Hardis: It is called "Named Groupes" I am capturing groups. http://stackoverflow.com/questions/906493/regex-named-capturing-groups-in-net – Jack May 15 '14 at 11:09
  • @Jack: You're right. Didn't even know those existed. – Andrew Whitaker May 15 '14 at 11:25