close

using System.Text.RegularExpressions;

Regex r = new Regex("(?i)<td>(.*)</td>", RegexOptions.IgnoreCase);
Match m = r.Match("<td>abc</td>\n<td>def</td>\n<td>ghi</td>\n<TD>jkl</td>");
while (m.Success)
{
    Console.WriteLine(m.Groups[1].Value);
    m = m.NextMatch();
}

得出
abc
def
ghi
jkl

如果沒有設定RegexOptions.IgnoreCase
則jkl不會出現
這個參數是在說不區分大小寫
如果還要加上其它屬性則以|區隔
例如RegexOptions.IgnoreCase | RegexOptions.Compiled


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 momokao 的頭像
    momokao

    momokao

    momokao 發表在 痞客邦 留言(0) 人氣()