Skip to content

Commit

Permalink
Implemented part 1 solution
Browse files Browse the repository at this point in the history
  • Loading branch information
absognety committed May 12, 2020
1 parent aee7021 commit b3acc79
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions DailyCodingProblem/implement_regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,28 @@
expression and returns whether or not the string matches the regular
expression.
For example, given the regular expression "ra." and the string "ray",
your function should return true. The same regular expression on the
string "raymond" should return false.
part - 1 :
For example, given the regular expression "ra." and the string "ray",
your function should return true. The same regular expression on the
string "raymond" should return false.
Given the regular expression ".*at" and the string "chat", your function
should return true. The same regular expression on the string "chats"
should return false.
"""
part - 2:
Given the regular expression ".*at" and the string "chat", your function
should return true. The same regular expression on the string "chats"
should return false.
"""

#part - 1 solution
def regex_match1(string,regex):
v = regex.split('.')
if v[0] != '':
t = v[0]
else:
t = v[1]
if (string.startswith(t) or string.endswith(t)):
if len(string) == len(t) + 1:
return 'true'
return 'false'
return 'false'

0 comments on commit b3acc79

Please sign in to comment.