Saturday, 7 September 2013

Regex returns value even when it doesn't match

Regex returns value even when it doesn't match

I have a regex like this:
string.match(/((?:website.com\/video\/)([\d]+))/);
When the string is supposed to match, everything is fine, however it
always returns something even if the string is "facebook.com", I still get
back "facebook.com", how can I make it return null?

No comments:

Post a Comment