A
Artūras Šlajus
ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
x11@www:~$ irb
irb(main):001:0> s = "www.myspace.com/djmamania
www.myspace.com/djmantini"
=> "www.myspace.com/djmamania www.myspace.com/djmantini"
irb(main):002:0> s1 = s.gsub(%r{(\s|^)(www\..*?)(\s|$)}m, '\1<a
href="http://\2">\2</a>\3')
=> "<a
href=\"http://www.myspace.com/djmamania\">www.myspace.com/djmamania</a>
www.myspace.com/djmantini"
irb(main):003:0> s1.gsub(%r{(\s|^)(www\..*?)(\s|$)}m, '\1<a
href="http://\2">\2</a>\3')
=> "<a
href=\"http://www.myspace.com/djmamania\">www.myspace.com/djmamania</a>
<a
href=\"http://www.myspace.com/djmantini\">www.myspace.com/djmantini</a>"
Why I have to call gsub two times for this to work? Same regexp works
fine in Firefox JS
x11@www:~$ irb
irb(main):001:0> s = "www.myspace.com/djmamania
www.myspace.com/djmantini"
=> "www.myspace.com/djmamania www.myspace.com/djmantini"
irb(main):002:0> s1 = s.gsub(%r{(\s|^)(www\..*?)(\s|$)}m, '\1<a
href="http://\2">\2</a>\3')
=> "<a
href=\"http://www.myspace.com/djmamania\">www.myspace.com/djmamania</a>
www.myspace.com/djmantini"
irb(main):003:0> s1.gsub(%r{(\s|^)(www\..*?)(\s|$)}m, '\1<a
href="http://\2">\2</a>\3')
=> "<a
href=\"http://www.myspace.com/djmamania\">www.myspace.com/djmamania</a>
<a
href=\"http://www.myspace.com/djmantini\">www.myspace.com/djmantini</a>"
Why I have to call gsub two times for this to work? Same regexp works
fine in Firefox JS