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
全站熱搜