Forum: Ruby what's wrong with my method and regular expression?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F1f64ada61619d15b958b1ad5164c601?d=identicon&s=25 equinox (Guest)
on 2008-12-18 01:10
(Received via mailing list)
The code is

http://pastie.org/341880

And i want it to return

nil
www.yahoo.co.in
/~testing/i.html

but when I run this code, why doesn't the www.yahoo.co.in detected?
23172b6630dc631a134c9bad2fec2a39?d=identicon&s=25 Chris Hulan (Guest)
on 2008-12-18 02:05
(Received via mailing list)
On Dec 17, 7:07 pm, equinox <aditya15...@gmail.com> wrote:
> The code is
>
> http://pastie.org/341880
>
> And i want it to return
>
> nilwww.yahoo.co.in
> /~testing/i.html
>
> but when I run this code, why doesn't thewww.yahoo.co.indetected?

You might want to play with your regex on Rubular (http://
rubular.com/)
A little experimentation shows that you probably want to include
'http://'
in your input string

cheers
F1f64ada61619d15b958b1ad5164c601?d=identicon&s=25 equinox (Guest)
on 2008-12-18 02:10
(Received via mailing list)
On Dec 17, 6:04 pm, Chris Hulan <chris.hu...@gmail.com> wrote:
>
> > but when I run this code, why doesn't thewww.yahoo.co.indetected?
>
> You might want to play with your regex on Rubular (http://
> rubular.com/)
> A little experimentation shows that you probably want to include
> 'http://'
> in your input string
>
> cheers

the code should work for both, if there's no http:// then it should
print out:

nil
www.yahoo.co.in
/~testing/i.html

if there is then it should print:

http
www.yahoo.co.in
/~testing/i.html
F1f64ada61619d15b958b1ad5164c601?d=identicon&s=25 equinox (Guest)
on 2008-12-18 02:23
(Received via mailing list)
On Dec 17, 6:08 pm, equinox <aditya15...@gmail.com> wrote:
> > > And i want it to return
> > in your input string
>
> httpwww.yahoo.co.in
> /~testing/i.html

anyway thanks for the rubular link I was able to fix the code using
it...
This topic is locked and can not be replied to.