Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Strings

2 views
Skip to first unread message

Jason Lillywhite

unread,
May 1, 2008, 10:29:34 PM5/1/08
to
Could someone help me convert a string with a number in it such as "26.7
feet" to just the word, "feet"?

I've searched documentation without luck. Thank you!
--
Posted via http://www.ruby-forum.com/.

David A. Black

unread,
May 1, 2008, 10:34:49 PM5/1/08
to
Hi --

On Fri, 2 May 2008, Jason Lillywhite wrote:

> Could someone help me convert a string with a number in it such as "26.7
> feet" to just the word, "feet"?
>
> I've searched documentation without luck. Thank you!

string[/\w+$/] would give you "feet". A lot depends on how you define
the operation you want (last sequence of characters, everything after
last number, etc.).


David

--
Rails training from David A. Black and Ruby Power and Light:
INTRO TO RAILS June 9-12 Berlin
ADVANCING WITH RAILS June 16-19 Berlin
INTRO TO RAILS June 24-27 London (Skills Matter)
See http://www.rubypal.com for details and updates!

0 new messages