Skip to content

Instantly share code, notes, and snippets.

View muthu1809's full-sized avatar

Muthuramalingam muthu1809

View GitHub Profile
def isPhoneNumber(text):
if len(text) != 10:
return False
for i in range(0, 9):
if not text[i].isdecimal():
return False
if text[0] == '0':
return False
return True
import re #முதலில் இதை இறக்கிக் கொள்ள வேண்டும் - நினைவிருக்கிறது அல்லவா!
def isMobileNumber(sentence): #def என்பது வேலையின் பெயருக்கு முன் கொடுக்கவேண்டிய பைத்தான் குறிச்சொல்.
mobileNumberPattern = re.compile("(0|91)[6-9][0-9]{9}")
return mobileNumberPattern.search(sentence)
#மேல் இருப்பது தான் நம்முடைய வேலை. இப்போது பைத்தானைக் கூப்பிட்டு இந்த வேலையைச் செய்யச் சொல்ல வேண்டுமே!
#கீழ் இருக்கும் வரிகளைப் பாருங்கள்.
sentence = "My mobile no is 918344777333"
mobileNumber_present = isMobileNumber(sentence) #இங்குத் தான், பைத்தானிடம் இந்த வேலையைச் செய்யச் சொல்கிறோம்.
import re
def isLandLine(sentence):
landLinePattern = re.compile(r'((91)((\d){2,4}))-([1-9][0-9]{5,8})')
present = landLinePattern.search(sentence)
std = len(present.group(1))
phone = len(present.group(5))
if (std+phone)==12:
return True
else:
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))
import re
def isMobileNumber(sentence):
mobileNumberPattern = re.compile("(91[6-9][0-9]{9})")
number = mobileNumberPattern.findall(sentence)
return number
sentence = "My mobile no is 918344777333 and 918883775533, 91234567890"
mobileNumber_present = isMobileNumber(sentence)
print(type(mobileNumber_present))
import re
def isMobileNumber(sentence):
mobileNumberPattern = re.compile("(91[6-9][0-9]{9})")
number = mobileNumberPattern.findall(sentence)
return number
sentence = "My mobile no is 918344777333 and 918883775533, 91234567890"
mobileNumber_present = isMobileNumber(sentence)
print(type(mobileNumber_present))
import re
datePattern = re.compile(r'([0-3][0-9])/([0-1][0-2])/((\d){4})')
dateFound = datePattern.search('My birthdate is 31/09/2000')
if not dateFound is None:
print(dateFound.groups())
day = dateFound.group(1)
month = dateFound.group(2).strip("0") # strip என்ன செய்யும் என்று கொஞ்சம் சிந்தியுங்களேன்.
year = dateFound.group(3)
print(day, month, year)
if int(month) in [1,3,5,7,8,10,12]:
import re # 1 re moduleஐ இறக்கிக் கொண்டோம்.
def passwordChecker(password):
if len(password)<8: #4: நீளம் அளக்கப்படுகிறது.
print("Password should have 8 characters")
else: # பெரிய எழுத்து,சிறிய எழுத்து, எண்கள் பார்க்கப்படுகின்றன.
if re.search("[a-z]", password) and re.search("[A-Z]",password) and re.search("[0-9]", password):
print("Strong Password")
else:
print("Password should have both upper and lower characters and has at least one digit")
import re # 1 re moduleஐ இறக்கிக் கொண்டோம்.
def passwordChecker(password):
if len(password)<8: #4: நீளம் அளக்கப்படுகிறது.
print("Password should have 8 characters")
else: # பெரிய எழுத்து,சிறிய எழுத்து, எண்கள் பார்க்கப்படுகின்றன.
if re.search("[a-z]", password) and re.search("[A-Z]",password) and re.search("[0-9]", password):
print("Strong Password")
else:
print("Password should have both upper and lower characters and has at least one digit")