I have something like<blockquote>
ending line like 1 store(s) .. I want to match , it using python regular expression.
I tried something like
but it's not working .
EDIT : adding the code , I tried
import re s = '1 store(s)' if re.match('store\(s\)$',s) : print('match')
In more or less direct reply to your comment<blockquote>
import re s = '1 stores(s)' if re.match('store\(s\)$',s): print('match')</blockquote>
The solution is to use
re.search instead of
re.match as the latter tries to match the whole string with the regexp while the former just tries to find a substring inside of the string that does match the expression.
Python offers two different primitive operations based on regular expressions: <strong>match</strong> checks for a match <strong>only at the beginning</strong> of the string, while <strong>search</strong> checks for a match <strong>anywhere</strong> in the string (this is what Perl does by default)</blockquote>
Straight <a href="http://docs.python.org/library/re.html#matching-vs-searching" rel="nofollow">from the docs</a>, but it does come up alot.Answer3:
have you considered