当前位置: 动力学知识库 > 问答 > 编程问答 >

regex - C# Regular Expression matching valid HTML attribute value

问题描述:

Does anyone have this Regular Expression?

 public static class HtmlAttributeValidator{

const bool REGEX_OPTIONS = RegexOptions.WhatGoesHere;

const string VALID_ATTRIBUTE_REGEX = @"What goes here?";

public static bool IsValidHtmlAttributeValue(string attributeValue){

return Regex.Match(attributeValue ?? string.Empty,

VALID_ATTRIBUTE_REGEX,

REGEX_OPTIONS);

}

}

网友答案:

You will not find such a regular expression, because many attribute values can take any valid textual value, hence the values are not regular and can't be matched by a regular expression.

See this list of HTML attributes and the values they can take. In particular note the ones that take CDATA values:

CDATA is a sequence of characters from the document character set and may include character entities.

分享给朋友:
您可能感兴趣的文章:
随机阅读: