我的html文本框上有def m_getWebSafeString(self, dirtyAttributeName):
cleanAttributeName = ''.join(dirtyAttributeName)
# Deal with beginning of string...
cleanAttributeName = re.sub('^[^a-zA-z]*','BEGINNING_',cleanAttributeName) # ORIGINAL REFERENCE
# --- ^ --- here
if "BEGINNING_" in cleanAttributeName:
print ' -- NEW STRING = {}'.format(cleanAttributeName)
return cleanAttributeName
而不是空格。
我正在尝试检查字符串是否已编码,即它是否为空格或
如何检查字符串是否为
的真实字符串
我试过这个但没有运气
答案 0 :(得分:1)
这不是文本编码,而是转换为HTML实体。
要检查您是否应该查看是否存在HTML实体。以下是此类单词的完整列表:
[" ","¡","¢","£","¤","¥","¦","§","¨","©","ª","«","¬","®","¯","°","±","²","³","´","µ","¶","·","¸","¹","º","»","¼","½","¾","¿","À","Á","Â","Ã","Ä","Å","Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û","Ü","Ý","Þ","ß","à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","÷","ø","ù","ú","û","ü","ý","þ","ÿ","&fnof","&Alpha","&Beta","&Gamma","&Delta","&Epsilon","&Zeta","&Eta","&Theta","&Iota","&Kappa","&Lambda","&Mu","&Nu","&Xi","&Omicron","&Pi","&Rho","&Sigma","&Tau","&Upsilon","&Phi","&Chi","&Psi","&Omega","&alpha","&beta","&gamma","&delta","&epsilon","&zeta","&eta","&theta","&iota","&kappa","&lambda","&mu","&nu","&xi","&omicron","&pi","&rho","&sigmaf","&sigma","&tau","&upsilon","&phi","&chi","&psi","&omega","&thetasym","&upsih","&piv","&bull","&hellip","&prime","&Prime","&oline","&frasl","&weierp","&image","&real","&trade","&alefsym","&larr","&uarr","&rarr","&darr","&harr","&crarr","&lArr","&uArr","&rArr","&dArr","&hArr","&forall","&part","&exist","&empty","&nabla","&isin","¬in","&ni","&prod","&sum","&minus","&lowast","&radic","&prop","&infin","&ang","&and","&or","&cap","&cup","&int","&there4","&sim","&cong","&asymp","&ne","&equiv","&le","&ge","&sub","&sup","&nsub","&sube","&supe","&oplus","&otimes","&perp","&sdot","&lceil","&rceil","&lfloor","&rfloor","&lang","&rang","&loz","&spades","&clubs","&hearts","&diams","&\"","&","<",">","&OElig","&oelig","&Scaron","&scaron","&Yuml","&circ","&tilde","&ndash","&mdash","&lsquo","&rsquo","&sbquo","&ldquo","&rdquo","&bdquo","&dagger","&Dagger","&permil","&lsaquo","&rsaquo","&euro"]
在字符串中进行正则表达式搜索,你会很好!
答案 1 :(得分:0)
根据答案的帮助,我发现它们是html实体,需要正则表达式,替换。
public class Destination
{
public string FlattenableProp1 { get; set; }
public string FlattenableProp2 { get; set; }
public MappedEmailAddress EmailAddress1 { get; set; }
public List<MappedEmailAddress> EmailAddresses
{
get
{
List<MappedEmailAddress> emails = new List<MappedEmailAddress>();
if (EmailAddress1 != null) emails.Add(EmailAddress1);
return emails;
}
set
{
if (value == null || value.Count == 0)
EmailAddress1 = new MappedEmailAddress();
else
EmailAddress1 = value[0];
}
}
}
如果有人将此代码转换为单个函数,那将对其他人有所帮助。