Broke out some of the inline RegExp from css.js. Goes towards fixing #4111.