111,126
社区成员
发帖
与我相关
我的任务
分享Regex r = new Regex(@"(?<=\b)align=['""]?\w+['""]?", RegexOptions.IgnoreCase);
string s = "<TD height=38 vAlign=top width=189 align=left> <FONT color=black size=2 face=Arial>This is textbox 2. It has TextAlign Left. </FONT> </TD>";
Console.WriteLine(r.Match(s));
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
Regex r = new Regex(@"align=?((?:\d+\.?\d*)|(?:[^\s;>}]+))");
string s="<TD height=38 vAlign=top width=189 align=left> <FONT color=black size=2 face=Arial>This is textbox 2. It has TextAlign Left. </FONT> </TD>";
Console.WriteLine(r.Match(s));
}
}
}
@"align=['""]?[^'""\s>]+['""]?" //双引号
@"align=['"]?[^'"\s>]+['"]?"