从 html 字符串中查找宏值的正则表达式
Regex to find macro value from a html string
在我的例子中 using c# ,来自 html(as string) 的方括号内的字符串必须找到,其中可能有白色 spaces在字符串 (ie) [userprinicipalname] 之后。也可能在 sting (ie) [ userprinicipalname] 之前有白色 space,因为它来自 html " " 是为白色 space 添加的(我使用了 trim(),但它不能在字符串之前添加 trim  )..因此,请帮助我了解 Regex 以仅在方括号内获得 trimmed(没有白色 spaces 或   前后)值?
请先用HttpUtility.HtmlDecode(html)
,再用Trim
您可以使用 Regex.Replace(source, @"^\s+", "");
或 sourceString.Replace(" ",string.empty)
。
(?<=[[; ])(\w+)
尝试使用此正则表达式匹配属性,
在我的例子中 using c# ,来自 html(as string) 的方括号内的字符串必须找到,其中可能有白色 spaces在字符串 (ie) [userprinicipalname] 之后。也可能在 sting (ie) [ userprinicipalname] 之前有白色 space,因为它来自 html " " 是为白色 space 添加的(我使用了 trim(),但它不能在字符串之前添加 trim  )..因此,请帮助我了解 Regex 以仅在方括号内获得 trimmed(没有白色 spaces 或   前后)值?
请先用HttpUtility.HtmlDecode(html)
,再用Trim
您可以使用 Regex.Replace(source, @"^\s+", "");
或 sourceString.Replace(" ",string.empty)
。
(?<=[[; ])(\w+)
尝试使用此正则表达式匹配属性,