\? not a valid evacuation symbol. Try replacing it with \\.
It looks like this:
var regexS = '[\\?&]' + name + '=([^&#]*)';
Keep in mind that the "\" escapes the character that appears after it. That's why \\ comes out as a single slash (if you look at the source of this question, you will find that I needed to quadruple the number \).
Other common escape sequences are: \ n for newlines and \ t for tabs.
source share