只有一个插入符的字符类有什么作用?
在尝试回答在找到特定字符时将文本写入新行这个问题时,我已使用 Regexp::Grammars。我长期以来对它很感兴趣,终于我有理由学习了。我注意到作者的描述部分有一个 LaTeX 解析器(我是一个狂热的 LaTeX 用户,所以这让我很感兴趣),但它有一个奇怪的构造,在这里看到:
<rule: Option> [^][\$&%#_{}~^\s,]+
<rule: Literal> [^][\$&%#_{}~^\s]+
What do the [^]
字符类完成?
In trying to answer the question Writing text into new line when a particular character is found, I have employed Regexp::Grammars. It has long interested me and finally I had reason to learn. I noticed that the description section the author has a LaTeX parser (I am an avid LaTeX user, so this interested me) but it has one odd construct seen here:
<rule: Option> [^][\amp;%#_{}~^\s,]+
<rule: Literal> [^][\amp;%#_{}~^\s]+
What do the [^]
character classes accomplish?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
[^][…]
不是两个字符类,而只是包含除]
、[
和之外的任何其他字符的一个字符类…
(参见特殊a 内的字符括号内的字符类):[^][…]
is not two character classes but just one character class containing any other character except]
,[
, and…
(see Special Characters Inside a Bracketed Character Class):