I’m new to Ruby, and just want to ask about how to read the following
statement from the “Agile Web D. With Rails, 3rd edition” book:
%r{.(gif|jpg|png)$}i
I knew that %r is a way to write a regular expression.
But, what is the $, and the i?
Thanks.
I’m new to Ruby, and just want to ask about how to read the following
statement from the “Agile Web D. With Rails, 3rd edition” book:
%r{.(gif|jpg|png)$}i
I knew that %r is a way to write a regular expression.
But, what is the $, and the i?
Thanks.
Abder-rahman Ali wrote:
%r{.(gif|jpg|png)$}i
I knew that %r is a way to write a regular expression.
But, what is the $, and the i?
http://www.ruby-doc.org/docs/ProgrammingRuby/html/language.html#UK
Brian C. wrote:
Abder-rahman Ali wrote:
%r{.(gif|jpg|png)$}i
I knew that %r is a way to write a regular expression.
But, what is the $, and the i?
Thanks Brian.
On Mon, Jun 14, 2010 at 5:24 PM, Abder-rahman Ali
[email protected] wrote:
I’m new to Ruby, and just want to ask about how to read the following
statement from the “Agile Web D. With Rails, 3rd edition” book:%r{.(gif|jpg|png)$}i
I knew that %r is a way to write a regular expression.
But, what is the $, and the i?
I always have this link handy:
$ matches the end of a line or string
i is a modifier that makes the regexp case insensitive.
Jesus.
On Mon, Jun 14, 2010 at 10:24 AM, Abder-rahman Ali <
[email protected]> wrote:
I’m new to Ruby, and just want to ask about how to read the following
statement from the “Agile Web D. With Rails, 3rd edition” book:%r{.(gif|jpg|png)$}i
It matches a dot, followed by either gif or jpg or png, at the end of
the
string. It does not care about case.
For example, it would match
foo.gif
foo.GiF
fOoO.jpg
bar.PNG
It would not match
foogif
foo.gif.
foo.giff
foo.jp
foo.pjg
foo.jpx
foo.jpg.csv
On Mon, Jun 14, 2010 at 12:24 PM, Abder-rahman Ali
[email protected] wrote:
I’m new to Ruby, and just want to ask about how to read the following
statement from the “Agile Web D. With Rails, 3rd edition” book:%r{.(gif|jpg|png)$}i
I knew that %r is a way to write a regular expression.
But, what is the $, and the i?
$ matches the end of the string and i makes the search case
insensitve. This is not Ruby specific, perphaps you should read about
regular expressions. See Ruby Regexp Class - Regular Expressions in Ruby
Bye
But, what is the $, and the i?
→ http://rubular.com/ → Regex quick reference
The \ escapes the . Thus . matches the ‘.’ character.
Marc W.
I suppose this shall help
please don’t print this e-mail unless you really need to.
On Mon, Jun 14, 2010 at 8:54 PM, Abder-rahman Ali <
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs