irb(main):070:0> a = 'Showing 1 to 10 of 72 Records'
=> "Showing 1 to 10 of 72 Records"
irb(main):071:0> a[/(\d+)\sto\s(\d+)\sof\s(\d+)/, 3]
=> "72"

I couldn't resist sharing this.  No disrespect to the other posters but I 
learned this trick from James Gray recently and think it's a really good trick. 
 This works since you can use a regexp in brackets to index a string.

You could also use:

a[/(\d+)\sto\s(\d+)\sof\s(\d+)/, 1]
or
a[/(\d+)\sto\s(\d+)\sof\s(\d+)/, 2]

...to get the other numbers.

Alan

This email message and any attachments are for the sole use of the intended 
recipients and may contain proprietary and/or confidential information which 
may be privileged or otherwise protected from disclosure. Any unauthorized 
review, use, disclosure or distribution is prohibited. If you are not an 
intended recipient, please contact the sender by reply email and destroy the 
original message and any copies of the message as well as any attachments to 
the original message.

-- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
watir-general+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/watir-general

Reply via email to