Uploaded by adilakshminarayanap

regular expressions 184617102080e398f70a63fa1982ca51 2

advertisement
import re
pattern = r"\d{3}" #2 digit numbers
text = " I joined in gitam in 2007 as Assistant Professor"
print(re.findall(pattern,text))
import re
pattern = r"\d{1,3}" #2 digit numbers
text = " I joined in gitam in 2007 as Assistant Professor at 9 Am"
print(re.findall(pattern,text))
import re
pattern = r"\b\d{1,3}\b" #2 digit numbers you can find your aadhar, Pan
number
text = " I joined in gitam in 2007 as Assistant Professor at 9 Am"
print(re.findall(pattern,text))
import re
pattern = r"\S" #White Spaces
text = " I joined in gitam in 2007 as Assistant Professor at 9 Am"
print(re.findall(pattern,text))
import re
pattern = r"[a-p]" # Characters
text = " I joined in gitam in 2007 as Assistant Professor at 9 Am"
print(re.findall(pattern,text))
import re
pattern = r"[a-p]|[0-9]" #number and digits
text = " I joined in gitam in 2007 as Assistant Professor at 9 Am"
print(re.findall(pattern,text))
import re
pattern = r"[A-Z]" #number and digits
text = " I joined in gitam in 2007 as Assistant Professor at 9 Am"
print(re.findall(pattern,text))
import re
pattern = r"Assist" #useful in text mining
text = " I joined in gitam in 2007 as Assistant Professor at 9 Am Assist"
print(re.findall(pattern,text))
import re
pattern = r"^joined" #begining
text = "I joined in gitam in 2007 as Assistant Professor at 9 Am Assist"
print(re.findall(pattern,text))
import re
pattern = r"gitam$" #ending
text = "I joined in gitam in 2007 as Assistant Professor at 9 Am Assist"
print(re.findall(pattern,text))
import re
pattern = r"Assist*" # likw 0 or more occurance of t followed by Assis
text = "I joined in gitam in 2007 as Assistant Professor at 9 Am Assis"
print(re.findall(pattern,text))
import re
pattern = r"Assist+" # likw 1 or more occurance of t followed by Assis
text = "I joined in gitam in 2007 as assistant Professor at 9 Am Assis"
print(re.findall(pattern,text,re.IGNORECASE))
import re
pattern = r"[^A-Z]" #number and digits
text = " I joined in gitam in 2007 as Assistant Professor at 9 Am"
print(re.findall(pattern,text))
import re
pattern = r"[0-7][0-9]" #number and digits
text = " I got 78 marks out of 99 in nlp"
print(re.findall(pattern,text))
import re
pattern = r"[A-Z][A-Z][A-Z][A-Z][A-Z][0-0][0-9][0-0][0-9][A-Z]"
number
text = " I got 78 marks out of 99 in nlp"
print(re.findall(pattern,text))
#Pan
Download