added functionality to return only the first match if fourth argument is supplied and `true`
normalised tabs and spaces