Skip to content
  • Pan GaoYong's avatar
    4e977da5
    `number_to_phone` formats number with regexp · 4e977da5
    Pan GaoYong authored
    By default, this method formats US number. This commit extends its
    functionality to format number for other countries with a custom regular
    expression.
    
        number_to_phone(18812345678, pattern: /(\d{3})(\d{4})(\d{4})/)
        # => 188-1234-5678
    
    The output phone number is divided into three groups, so the regexp
    should also match three groups of numbers.
    4e977da5
    `number_to_phone` formats number with regexp
    Pan GaoYong authored
    By default, this method formats US number. This commit extends its
    functionality to format number for other countries with a custom regular
    expression.
    
        number_to_phone(18812345678, pattern: /(\d{3})(\d{4})(\d{4})/)
        # => 188-1234-5678
    
    The output phone number is divided into three groups, so the regexp
    should also match three groups of numbers.
Loading