New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`number_to_phone` formats number with regexp #24401

Merged
merged 1 commit into from Apr 5, 2016

Conversation

Projects
None yet
5 participants
@pan
Contributor

pan commented Apr 2, 2016

Summary

By default, the helper method number_to_phone formats US number. This commit extends its functionality to format number for other countries with a custom regular expression. For example,
formatting a non-us mobile number,

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.

`number_to_phone` formats number with regexp
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.
@rails-bot

This comment has been minimized.

rails-bot commented Apr 2, 2016

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @sgrif (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rafaelfranca rafaelfranca merged commit 4e977da into rails:master Apr 5, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

rafaelfranca added a commit that referenced this pull request Apr 5, 2016

Merge pull request #24401 from pan/number-to-phone
`number_to_phone` formats number with regexp

vipulnsward added a commit to vipulnsward/rails that referenced this pull request Apr 5, 2016

rafaelfranca added a commit that referenced this pull request Apr 5, 2016

Merge pull request #24429 from vipulnsward/24401-docs
Guides changes, follow up of #24401 [ci skip]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment