I want to trim down a phone number to the last four digits before saving it to the db. How would I do this? For example, 800-555-1212 which could also be 8005551212, i want to save just 1212 (last four digits) only. -- Posted via http://www.ruby-forum.com/.
Neeraj Kumar
2006-Jul-31 12:26 UTC
[Rails] getting the last four digits of a string or number
phone_number = "number here" last_four_digits = phone_number[phone_number.length - 4 ,4] -=- On 7/31/06, Greg N. <greg@busyashell.com> wrote:> > I want to trim down a phone number to the last four digits before saving > it to the db. How would I do this? For example, 800-555-1212 which > could also be 8005551212, i want to save just 1212 (last four digits) > only. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060731/84368a4d/attachment.html
Greg N.
2006-Jul-31 12:41 UTC
[Rails] Re: getting the last four digits of a string or number
Neeraj Kumar wrote:> phone_number = "number here" > last_four_digits = phone_number[phone_number.length - 4 ,4] > > -=-Thanks Neeraj! -- Posted via http://www.ruby-forum.com/.