Shoudl be : 
````
if (typeof groups[1] !== 'undefined') {
````