Strings

  • Thread starter Jason Lillywhite
  • Start date
J

Jason Lillywhite

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!
 
D

David A. Black

Hi --

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,205
Messages
2,571,067
Members
47,673
Latest member
MahaliaPal

Latest Threads

Top