From: Mike Stok Date: 2002-12-20T10:58:16+09:00 Subject: Re: regex help please please ! In article , Matthew, Graeme wrote: > Please could someone assist as im now bald with a pile of hair around my > chair ! > How does one do greedy regex's in ruby ? in Perl / Python one has access to > the /s or .DOTALL option but in ruby I cannot get a greedy effect. By "greedy" I assume you mean make the . metacharacter match anything including a new line. (Normally greed in regexps is used in the context of how much of the string is "consumed" by quantified atoms, but I'm guessing from the context.) Do you want the m modifier? e.g. (in irb) irb(main):001:0> languages = "ruby\nperl\npython" => "ruby\nperl\npython" irb(main):002:0> languages =~ /(r.*y)/ && $1 => "ruby" irb(main):003:0> languages =~ /(r.*y)/m && $1 => "ruby\nperl\npy" or if pythonesque verbosity is what you're after irb(main):004:0> Regexp.new('(r.*y)', Regexp::MULTILINE).match(languages)[1] => "ruby\nperl\npy" Hope this helps, Mike -- mike@stok.co.uk | The "`Stok' disclaimers" apply. http://www.stok.co.uk/~mike/ | GPG PGP Key 1024D/059913DA mike@exegenix.com | Fingerprint 0570 71CD 6790 7C28 3D60 http://www.exegenix.com/ | 75D2 9EC4 C1C0 0599 13DA