Ruby的正则表达式行为在哪里记录? [英] Where is Ruby's regexp behavior documented?

查看:147
本文介绍了Ruby的正则表达式行为在哪里记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道正则表达式文档,但是,这里有两个绝对关键的是,Regexp类没有记录的东西:

I am aware of the Regex documentation, however, here are two absolutely critical things the Regexp class does that are not documented there:


  1. ^ $ 匹配行开始和结束,而不是字符串开始( \A )和结束( \Z )。在其他语言中,像Perl一样,默认情况下, ^ 和 $ 将匹配字符串start / end。这个行为实际上是perlre文档解释的第一件事。

  1. ^ and $ match the line start and end, not string start (\A) and end (\Z). In other languages, like Perl, ^ and $ will match the string start/end by default. This behavior is in fact one of the very first things the perlre documentation explains.

/ m (多行)标志导致。匹配换行符。 Ruby文档只会说这个标志是存在的,而不是它实际上是什么。

The /m (multi-line) flag causes "." to match newlines. The Ruby docs only say this flag exists, not what it actually does.

对Ruby正则表达式的行为规范进行了记录?或者我们都应该在这些事情上深深地感受到我们的方式吗?

Is there nowhere that the full and complete specification of behavior for Ruby regular expressions is documented? Or are we all supposed to feel our way through the dark on these things?

推荐答案

可以从官方访问Regexp文档文件网站: http://ruby-doc.org/core-1.9.3/ Regexp.html

The Regexp documentation can be accessed from the official documentation site: http://ruby-doc.org/core-1.9.3/Regexp.html

这篇关于Ruby的正则表达式行为在哪里记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆