>>> def matcher(regex,string):
match=re.search(regex, string)
if match is None: return string
start,end=match.span()
return string[:start] + '<<' + string[start:end] + '>>' + string[end:]
>>> matcher(r'(\w+).*\1', 'Matches str if str repeats one of its words.')
Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
matcher(r'(\w+).*\1', 'Matches str if str repeats one of its words.')
File "<pyshell#10>", line 2, in matcher
match=re.search(regex, string)
NameError: global name 're' is not defined
Защо се получава така, какво съм му направил на питона !?????