some perl and vanilla regex boilerplate