Open
Conversation
Adding Regex for Phone Numbers in EGYPT
Contributor
|
This might actually be a good time to look at using something more general. I was able to get import phonenumbers
from phonenumbers.phonemetadata import PhoneMetadata
metadata = PhoneMetadata.metadata_for_region("EG") # Replace "US" with the country code you need
metadata.number_format
# [NumberFormat(pattern='(\\d)(\\d{7,8})', format='\\1 \\2', leading_digits_pattern=['[23]'], national_prefix_formatting_rule='0\\1'), NumberFormat(pattern='(\\d{2})(\\d{6,7})', format='\\1 \\2', leading_digits_pattern=['1[35]|[4-6]|8[2468]|9[235-7]'], national_prefix_formatting_rule='0\\1'), NumberFormat(pattern='(\\d{3})(\\d{3})(\\d{4})', format='\\1 \\2 \\3', leading_digits_pattern=['[89]'], national_prefix_formatting_rule='0\\1'), NumberFormat(pattern='(\\d{2})(\\d{8})', format='\\1 \\2', leading_digits_pattern=['1'], national_prefix_formatting_rule='0\\1')]Not quite sure how to combine these though. |
Member
|
Thank you for your contribution! You need to add the Egypt locale in this file: outlines/outlines/types/locales.py Line 7 in 289ef5d types.locale("eg").PhoneNumber |
Contributor
|
Hi @ahmeda335! We modified the organization of the output type files in the recently released Outlines v1. |
rlouf
reviewed
Jun 19, 2025
| # Phone numbers in Egypt. | ||
| EGYPT_PHONE_NUMBER = r"^01[0-2,5]{1}[0-9]{8}$" | ||
|
|
||
| EgpytPhoneNumber = Annotated[ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adding Regex for Phone Numbers in EGYPT