Are the angle brackets (< or>) special in a regular expression?

前端 未结 2 870
时光说笑
时光说笑 2020-12-01 20:46

I am trying to get a regex expression to accept < and > as my outside delimiters to grab all the content in between them.

so content like such

<         


        
2条回答
  •  醉话见心
    2020-12-01 21:46

    Neither < nor > are metacharacters inside a regular expression.

    This works for me:

    ' and '.match(/<[^>]*>/g); // ["", ""]
    

提交回复
热议问题