Addressing issue #203

the regex was resulting in undefined, this checks if undefined, and
if so then just return harmless empty string rather than trying to
invoke string methods on undefined.