Last active
January 4, 2020 15:54
-
-
Save eshafik/4b4e5364904930e706d6a62366d34cda to your computer and use it in GitHub Desktop.
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
| import re | |
| text_1 = "I live in Bangladesh" | |
| text_2 = "I speak Bangla" | |
| textRegex = re.compile(r"Bangla(desh)?") # 0 or one time. | |
| print(textRegex.search(text_1)) | |
| # Output: | |
| <re.Match object; span=(10, 20), match='Bangladesh'> | |
| print(textRegex.search(text_2)) | |
| # Output: | |
| <re.Match object; span=(8, 14), match='Bangla'> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment