Trying to implement a subset of regex in js...