Skip to content

Instantly share code, notes, and snippets.

@muthu1809
Created July 23, 2020 16:53
Show Gist options
  • Save muthu1809/cd1781e6d8421d40e01f787695687afe to your computer and use it in GitHub Desktop.
Save muthu1809/cd1781e6d8421d40e01f787695687afe to your computer and use it in GitHub Desktop.
landlinewithzerocode.py
import re
def isLandLine(sentence):
landLinePattern = re.compile(r'(((91|0)((\d){2,4}))-)?([1-9][0-9]{5,8})')
present = landLinePattern.search(sentence)
if present.group(1)==None:
std=0
else:
std=len(present.group(1))
phone = len(present.group(5))
if (std+phone)==12: or 11:
return True
else:
return False
sentence = 'My number is 0462-2921129'
landline_present = isLandLine(sentence)
if(landline_present):
print("Landline number is present in the sentence")
else:
print("Landline Number is not present in the sentence")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment