I\'m looking for a regular expression that matches the \'>\' in
a > b
>
b>
...
but not two or more angled brackets, i.e. it should
perreal's first regex is correct. However, the second regex given in that answer subtly fails in one condition. Since it captures characters both before and after, two >
s separated by a single character will not both be found.
Here is a regex which only uses forward lookaheads and doesn't have that problem:
(?:^|[^>])(>)(?:$|(?!>))
Edit live on Debuggex