最长和最短的 HTML 字符实体名称是什么? [英] What are the longest and shortest HTML character entity names?

查看:25
本文介绍了最长和最短的 HTML 字符实体名称是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

管子周围有一百万个备忘单,列举了不同版本和规范的 HTML 指定的字符实体的不同理解水平.我不想相信他们中的任何一个,所以我想我会把它扔在这里,看看是否有人发布了更权威的答案.

There are a million cheatsheets all around the tubes that enumerate to different levels of comprehension the character entities specified by various versions and specifications of HTML. I don't want to trust any particular one of them, so I figure I'll toss it out here and see if anyone posts a more authoritative answer.

所以,让我们假设我想使用正则表达式匹配任何和所有字符引用和实体.我会从 /&(?:#(?:x[0-9a-f]+|[0-9]+)|[az]{???,???}); 开始/i.但是什么会进入 ??? s?我可以想到两个字符长的实体,例如 ltgt,但是在 HTML 的任何规范中是否有任何单字母实体?同样,最长的实体是什么?最后,这些除了直接输入它们之外,用于在 HTML 中表达文字字符的仅有的三种语法,不是吗?

So, let's assume that I want to match any and all character references and entities using a regular expression. I'd start with /&(?:#(?:x[0-9a-f]+|[0-9]+)|[a-z]{???,???});/i. But what would go into ???s? I can think of entities that are two characters long, like lt and gt, but are there any one-letter entities in any specifications of the HTML? Likewise, what is the longest entity? Finally, those are the only three syntaxes for expressing literal characters in HTML aside from just typing them directly, are they not?

推荐答案

HTML5 中最长的是 &CounterClockwiseContourIntegral;,并且没有一个字母的名字.

Longest in HTML5 is &CounterClockwiseContourIntegral;, and there are no one-letter names.

但请注意,命名实体引用并不像您想象的那样工作.一些命名的字符引用不以分号结尾,因此正则表达式不会削减芥末.

But note that named entity references don't work as you think. Some named character references don't end with a semi-colon, so a regex won't cut the mustard.

这篇关于最长和最短的 HTML 字符实体名称是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆