From: Benoit Daloze Date: 2009-12-14T19:17:26+09:00 Subject: Re: problem with trivial regular expression --00163641690f492212047aad942c Content-Type: text/plain; charset=ISO-8859-1 irb> s = "fajljsfjaosfohttp://www.marca.comjafosjodfahttp://www.as.comjfoaasjofja" => "fajljsfjaosfohttp://www.marca.comjafosjodfahttp://www.as.comjfoaasjofja" irb> s.scan( %r{http://.+?\.com} ) => ["http://www.marca.com", "http://www.as.com"] I use scan because we want multiple results. For the Regexp, in ".+?", you make it ungreedy The %r{} let you write / without escaping I also add a "\." to ensure there is a point before "com" Enjoy 2009/12/14 David Villa > > hi ,sorry for my english. > > I am trying to remember the use of regular expressions and i have a > problem with this : > > i had a text with diferents strings, for example, url , like this : > > fajljsfjaosfohttp://www.marca.comjafosjodfahttp://www.as.comjfoaasjofja > > i want to extract the diferents url but i try with : > /(http\:\/\/.+com)/ it returns a long match: > > > > 1. http://www.marca.comjafosjodfahttp://www.as.com > > > how can i group this in 2 diferents matchs? example : > 1- http://www.marca.com > 2- http://www.as.com > > > thanks > -- > Posted via http://www.ruby-forum.com/. > > --00163641690f492212047aad942c--