ruby – 各种Regexp选项
发布时间:2020-12-17 03:06:53 所属栏目:百科 来源:网络整理
导读:Ruby的正则表达式文字可以采用记录的选项i,m,x.但除此之外,它还可以接受更多种类的选择.以下是似乎允许的选项清单: //e # = ////i # = //i ignore case//m # = //m multiline//n # = //n//o # = ////s # = ////u # = ////x # = //x extended 他们做了什么?
Ruby的正则表达式文字可以采用记录的选项i,m,x.但除此之外,它还可以接受更多种类的选择.以下是似乎允许的选项清单:
//e # => // //i # => //i ignore case //m # => //m multiline //n # => //n //o # => // //s # => // //u # => // //x # => //x extended >他们做了什么?其中一些与编码有关吗?别人怎么样? 如果有文档,请链接到该文档. 解决方法
正则表达式修饰符:
正则表达式文字可以包括可选的修饰符来控制匹配的各个方面.修饰符在第二个斜杠字符后面指定,如前所示,可以用以下字符之一表示: Modifier Description i Ignore case when matching text. o Perform #{} interpolations only once,the first time the regexp literal is evaluated. x Ignores whitespace and allows comments in regular expressions m Matches multiple lines,recognizing newlines as normal characters u,e,s,n Interpret the regexp as Unicode (UTF-8),EUC,SJIS,or ASCII. If none of these modifiers is specified,the regular expression is assumed to use the source encoding. source 注意:上面的描述有附带条件.请参阅sawa的答案. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |