Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
\p{Alnum}Ruby 语言的正则表达式中的类是什么?它包含哪些字符,它与 有何不同[:alnum:]?
\p{Alnum}
[:alnum:]
基于rdoc和本教程,这两个表达式是等价的。
它们包含字母和数字字符。如果只使用 ASCII 字符,则相当于[a-zA-Z0-9]. 如果有非 ASCII 字符,则两者都[:alnum:]包括p{Alnum}重音字符之类的内容。
[a-zA-Z0-9]
p{Alnum}