My first stackoverflow question! So let me know if I could have gone a better route getting this information / if I suck at phrasing my questions well in search. :) meanwhile... ONWARDS TO THE QUESTION!
So I have a regex function:
s = "benisasillyhehehe"; //this would be variable
regex = /benisasilly(.*)/;
console.log(s.match(regex));
and what I want to do is log what's appended to "benisasilly" if it exists, and log null if it doesn't. But what ends up happening is that it logs an empty string instead. Is there a way to incorporate this functionality into a regex function, or should I just check it all outside this function? Also, does it even really matter? I mostly just wanted to do it because I have other regex functions that I'm using in the same system that DO give null, so I would prefer them to all have the same output format. Thanks a toooon! :D
Edit: Let me clarify a little more. This is the output I'm hoping for:
[ 'benisasillyhehehe','hehehe', index: 0, input: 'benisasillyhehehe' ]
and then
null
if it doesn't work.
Currently, when it doesn't work, I get:
[ 'benisasilly', '', index: 0, input: 'benisasilly' ]
So actuallyfor me, null vs empty string is important in that I want the match to fail vs having the match return an empty string.
.*to.+?