Skip to content

Commit

Permalink
use regex escape sequences to shorten stuff up
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Oct 18, 2010
1 parent 081e15f commit 9c219bf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions actionpack/lib/action_view/helpers/number_helper.rb
Expand Up @@ -64,9 +64,9 @@ def number_to_phone(number, options = {})
country_code = options[:country_code]

if area_code
number.gsub!(/([0-9]{1,3})([0-9]{3})([0-9]{4}$)/,"(\\1) \\2#{delimiter}\\3")
number.gsub!(/(\d{1,3})(\d{3})(\d{4}$)/,"(\\1) \\2#{delimiter}\\3")
else
number.gsub!(/([0-9]{0,3})([0-9]{3})([0-9]{4})$/,"\\1#{delimiter}\\2#{delimiter}\\3")
number.gsub!(/(\d{0,3})(\d{3})(\d{4})$/,"\\1#{delimiter}\\2#{delimiter}\\3")
number.slice!(0, 1) if number.starts_with?('-')
end

Expand Down

0 comments on commit 9c219bf

Please sign in to comment.