Reputation: 319
I have a url pattern: "somepath/email/". I don't want to write a regex for matching email instead I want anything which isn't a path separator to match email.
Please suggest a regex for this. I am using Python and the url is for a Django application, So any library function will also be helpful but I will prefer a regex.
Upvotes: 3
Views: 1407
Reputation: 41848
The regex [^/\\]+
is a negative character class with a +
quantifier and matches any number of characters that are not a /
or \\
Code sample:
match = re.search("[^/\\]+", subject)
if match:
result = match.group()
else:
result = ""
Upvotes: 2