Ruby定义一个正则表达式
示例
可以在Ruby中以三种不同的方式创建Regexp。
使用斜杠://
使用%r{}
使用Regex.new
#以下形式是等效的
regexp_slash=/hello/
regexp_bracket=%r{hello}
regexp_new=Regexp.new('hello')
string_to_match="你好,世界!"
#所有这些将返回真实值
string_to_match=~regexp_slash #=>0
string_to_match=~regexp_bracket #=>0
string_to_match=~regexp_new #=>0
热门推荐
1 训练狗狗工作
4 狗狗定点排便训练
5 狗狗训练吠叫
6 狗狗尿垫训练
7 狗狗训练座
8 狗狗训练攻略
9 狗狗训练记
10 做训练狗狗
11 狗狗训练词
12 狗狗谢谢怎么训练
13 狗狗训练如厕
14 狗狗太凶怎么训练
15 狗狗训练它
16 狗狗克制训练
17 训练基地狗狗
18 怎么样训练狗狗大小硬