I am trying to extract a query string from my URL using JavaScript, and I need to perform a case-insensitive comparison for the query string name. In order to achieve this, here is the code snippet that I am currently using:
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
if (!results) { return 0; }
return results[1] || 0;
However, the code above performs a case-sensitive search. I attempted using /<regex>/i
but it did not provide the desired outcome. Do you have any suggestions on how I can accomplish a case-insensitive search?