Skip to content
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

Create your own number format #119

Closed
Koyirov opened this issue May 22, 2018 · 4 comments
Closed

Create your own number format #119

Koyirov opened this issue May 22, 2018 · 4 comments
Labels

Comments

@Koyirov
Copy link

Koyirov commented May 22, 2018

Hello,
Can someone show me an example how to create your own number format. I need "+49 xxx xxxxxxxxx" format to use the function format_by_pattern(num_obj, NumberFormat, new_number_format). I haven't found on the Internet an example for python. Thank you in advance.

@daviddrysdale
Copy link
Owner

There are examples of format_by_pattern in the tests.

@Koyirov
Copy link
Author

Koyirov commented May 23, 2018

Thank you very much!

@Koyirov
Copy link
Author

Koyirov commented May 23, 2018

There is my code:

number = '+491623276631'
num_obj = ph.parse(number)

new_number_format = ph.NumberFormat(pattern="(\d{3})(\d{*})", format="\1 \2")
new_number_format._mutable = True
newNumberFormats = [new_number_format]

new_form = ph.format_by_pattern(num_obj, ph.PhoneNumberFormat.INTERNATIONAL, newNumberFormats)
print(new_form).

but I can't get my desired result. The result is '+49 1623276631', I want to have '+49 162 3276631'. What's the problem here?

@Koyirov
Copy link
Author

Koyirov commented May 23, 2018

the problem has been solved. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants