Ruby 正则表达式
这里只是介绍一些 Ruby 里不常用的 Regexp 的知识。后面这两个知识点具体看 Read Ruby 。
[] 的写法
今天发现了一个 Ruby 正则表达式 extract 的直接写法
verb = request_line[/^\w+/]
url = request_line[/^\w+\s+(\S+)/, 1]
Character Classes
/[[:alnum:]]/
Simple Properties
"中文" =~ /\p{Ideographic}/
Ideographic “Characters considered to be CJKV (Chinese, Japanese, Korean, and Vietnamese) ideographs.” (ibid.)