Can somebody help me figure out what is the issue with the below code:
import re
class RegexTest(object):
def regex_test(self, reg, string):
reg_pattern = repr(reg)[1:-1]
match = re.search(reg_pattern, string)
if (match is not None):
return match.group(0)
else:
return None
test = RegexTest()
print(test.regex_test('[A-Za-z0-9\._]+\@\w+\.\w{2,4}', 'My email id is: abcd123_hello@yahoo.com'))
Output:
None
Any help would be highly appreciated.