Regular Expression to match only one angle bracket

后端 未结 3 923
轻奢々
轻奢々 2020-12-21 22:47

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

3条回答
  •  孤城傲影
    2020-12-21 23:23

    Perl syntax:

    /(?)>(?!>)/
    

    Without using lookahead or lookbehind:

    /(?:^|[^>])>(?:[^>]|$)/
    

提交回复
热议问题