Forum: Ruby on Rails how to search the phrase of numbers

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.
1f47aa8b39bba61ec339854722e7657f?d=identicon&s=25 Dina Z. (dina_z)
on 2013-11-09 02:54
Hi,Dear all,

I am trying to search the phrase of numbers in a html page in the
sentence below:

<div class="Results" id="yui_3_11_0_4_1383957936583_5009">(253
items)</div>

I used this piece of code, but it does not work,

limit= page.search("div[class=Results]").search("div").gsub("items","")

         begin
       Integer(limit)
    rescue
       return 0
   end

Would you give me any suggestion on this?

Thank you,
Regards,
Di
Aa082c8b00a50928e5860dcd70bf2368?d=identicon&s=25 tamouse m. (tamouse_m)
on 2013-11-09 23:58
(Received via mailing list)
On Nov 8, 2013, at 7:54 PM, Dina Z. <lists@ruby-forum.com> wrote:

> limit= page.search("div[class=Results]").search("div").gsub("items","")
>
>         begin
>       Integer(limit)
>    rescue
>       return 0
>   end
>
> Would you give me any suggestion on this?

Break apart the chain of method calls above, and see what each is
returning.
This topic is locked and can not be replied to.