File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111expression and returns whether or not the string matches the regular
1212expression.
1313
14- For example, given the regular expression "ra." and the string "ray",
15- your function should return true. The same regular expression on the
16- string "raymond" should return false.
14+ part - 1 :
15+ For example, given the regular expression "ra." and the string "ray",
16+ your function should return true. The same regular expression on the
17+ string "raymond" should return false.
1718
18- Given the regular expression ".*at" and the string "chat", your function
19- should return true. The same regular expression on the string "chats"
20- should return false.
2119
22- """
20+ part - 2:
21+ Given the regular expression ".*at" and the string "chat", your function
22+ should return true. The same regular expression on the string "chats"
23+ should return false.
24+
25+ """
26+
27+ #part - 1 solution
28+ def regex_match1 (string ,regex ):
29+ v = regex .split ('.' )
30+ if v [0 ] != '' :
31+ t = v [0 ]
32+ else :
33+ t = v [1 ]
34+ if (string .startswith (t ) or string .endswith (t )):
35+ if len (string ) == len (t ) + 1 :
36+ return 'true'
37+ return 'false'
38+ return 'false'
You can’t perform that action at this time.
0 commit comments