make match safe

`String.prototype.match` returns `null` if there is no match. For example:

```javascript
> 'abc'.match(/x/)
null
```

This change is largely copied from #13.