Case insensitive regex in JavaScript

前端 未结 4 1021
-上瘾入骨i
-上瘾入骨i 2020-11-22 12:33

I want to extract a query string from my URL using JavaScript, and I want to do a case insensitive comparison for the query string name. Here is what I am doing:

<         


        
4条回答
  •  孤街浪徒
    2020-11-22 13:13

    modifiers are given as the second parameter:

    new RegExp('[\\?&]' + name + '=([^&#]*)', "i")
    

提交回复
热议问题