Reputation: 3951
I'd like to perform a regexp search operation in python to match everything, but one character (which in this example is at the end):
expression = re.compile(r'http:\/\/.*')
The above regular expression would match whole url: http://stackoverflow.com/questions/ask;
and what I want to do is to get a match without the final ;
character.
Upvotes: 1
Views: 1734
Reputation: 213261
You can use a negated character class instead of dot (.)
at the end: -
expression = re.compile(r'http:\/\/[^;]*')
Upvotes: 1