Fix regex to make it work in js

js regex too terrible.