Do I have this line: #test or #test?params=something
var regExp = /(^.*)?\?/; var matches = regExp.exec($(this).data('target')); var target = matches[1]; console.log(target);
I always need to get only #test. A nested function returns an error if a question mark is not found. The goal is to always return #test if there are additional options or not. How to create a regex that returns this?
source share