Last active
August 2, 2018 10:21
-
-
Save Anwarvic/3a13d41ceabbdb628593297a79fbde63 to your computer and use it in GitHub Desktop.
In this gist, I will write regular expressions for different purposes (incremental)
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
| """ | |
| extract names like: | |
| Mohamed Anwar | |
| Mohamed Anwar Ghanem | |
| Mohamed Anwar Saeed Ghanem | |
| but not: | |
| Mohamed | |
| Mohamed A. Ghanem | |
| """ | |
| regex = r'(([A-Z]{1}[a-z]+)\s){2,}' | |
| ########################################### | |
| """ | |
| extract numbers like: | |
| 1st, 2nd, 3rd, 4th | |
| 123 | |
| 12.345 | |
| 12. | |
| 01,234,567 | |
| """ | |
| regex = r'(([0-9])+(th|st|nd|rd|\s))|([0-9]{0,2},([0-9]{3})+)|([0-9]+.[0-9]*)' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment