-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram60.py
More file actions
35 lines (29 loc) · 774 Bytes
/
program60.py
File metadata and controls
35 lines (29 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#Regular expressions---------
#match,search,find ----------all
#match----------
import re
pattern = r"color"
if re.match(pattern,"color red is color, I love red Color"):
print("Match")
else:
print("Not Match")
#search---------
import re
pattern = r"Arif"
if re.search(pattern,"who is a student,Arif learn python programming language"):
print("Match")
else:
print("Not Match")
#Find all-----
import re
pattern = r"color"
print(re.findall(pattern,"This red is red color, I love red color"))
#More on search fuction----------
import re
pattern = r"color"
text = "This red is red color, I love red color"
match = re.search(pattern,text)
if match:
print(match.start())
print(match.end())
print(match.span())