Regular Expression String Length Function In Javascript With Parameters