Javascript regex invalid range in character class

后端 未结 2 691
温柔的废话
温柔的废话 2020-12-16 20:47

I\'m using a regex pattern that I got from regexlib to validate relative urls. On their site you can test the pattern to make sure it fits your needs. Everything works great

2条回答
  •  时光说笑
    2020-12-16 21:46

    Either put - at the end or beginning of the character class or use two backslashes to do a regex escape within string

    since you are using string you need to use two backslashes for each special characters..


    NOTE

    Check out this answer on SO which explains when to use single or double backslashes to escape special characters

提交回复
热议问题