I have an application that stores phone numbers as '+11231231234'. To make it easier for the user, I convert it to: +1(123) 123-1234 in the view. I use the number_to_phone helper in rails to do it:
<%= number_to_phone(call.From, :area_code => true) %>
I also want to remove the +1 from the view. What would I need to write to remove the first two characters of the phone number if the first two characters are +1?
number_to_phone(call.From, :area_code => true).gsub(/^\+\d/, '')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With