Skip to content

Commit b3acc79

Browse files
committed
Implemented part 1 solution
1 parent aee7021 commit b3acc79

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

DailyCodingProblem/implement_regex.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,28 @@
1111
expression and returns whether or not the string matches the regular
1212
expression.
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'

0 commit comments

Comments
 (0)