I have a simple query string in my program:
?username=someone@email.com&fname=
I have come up with a regular expression that selects everything except the data I want:
[^a-zA-Z0-9.@]|(username|fname)
I am trying to use javascripts str.split() to split around everything that isn't actually data in the query, like so:
let userinfo = global.location.search.split(/[^a-zA-Z0-9.@]|(username|fname)/).filter(Boolean);
Unfortunately, when this runs, I get the following array:
['username', 'someone@email.com', 'fname']
.
I expect just ['someone@email.com']
since "username" and "fname" should be split around from my regex.
I have tested this in https://regex101.com/ and it appears to work fine, so I'm not sure why it doesn't work in JS.
Any ideas?