Regex - match returns None. Where am I wrong?
python, regex
Solution
Use
match1 = reg1.search(s)
instead. The `match` function only matches at the start of the string ... see the documentation here:
Python offers two different primitive operations based on regular expressions: `re.match()` checks for a match only at the beginning of the string, while `re.search()` checks for a match anywhere in the string (this is what Perl does by default).
Problem
``` >>> import re >>> s = 'this is a test' >>> reg1 = re.compile('test$') >>> match1 = reg1.match(s) >>> print match1 None ``` in Kiki that matches the test at the end of the s. What do I miss? (I tried `re.compile(r'test$')` as well)