I want to match all combinations of <>=/*+-
except for =
and =>
. How can I do this?
r = re.compile(r'[<>=/*+-]+')
This matches one or more characters in the set but I don't know how to prevent it from matching the =
or =>
patterns. I'd guess it has something to do with negative lookahead or lookbehind but it's hard for me to wrap my head around that.
clarification: I literally want to match all combinations of the characters in <>=/*+-
except for =
and =>
. In other words, I want to find maximal-length consecutive substrings consisting only of these characters -- and if the substring equals =
or =>
, it should not be considered a match.
I apologize for not clarifying earlier, but it seemed like a simple enough problem statement not to need the extra clarification.
Example cases:
pow pow -> bah bah
contains the match->
a +++->* b // c
contains the matches+++->*
and//
=> 3 <= 4 = 5 == 6
contains the matches<=
and==
(remember,=
and=>
are not matches)a <=> b <@> c
contains the matches<=>
and<
and>
---= =---
contains the matches---=
and=---