Thursday, January 24, 2013

Some useful regular expressions

HTML tags:
/<\/?[a-zA-Z][a-zA-Z0-9]*(\s+[a-zA-Z0-9]+=("|')[^("|')]+("|'))*(\s*\/)*>/g

Valid name:
/^(?:[A-Za-z]+(?:\s|$)){1,4}$/

Valid email:
/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix


No comments:

Post a Comment