这段代码提供了几个常用的正则
//replace all but links /<(?!\/?a(?=>|\s.*>))\/?.*?>/g //validate url /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \?=.-]*)*\/?$/ //Validate US phone number /^(\+\d)*\s*(\(\d{3}\)\s*)*\d{3}(-{0,1}|\s{0,1})\d{2}(-{0,1}|\s{0,1})\d{2}$/ //Test if a password is strong (?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$ //Validate US zip code ^[0-9]{5}(-[0-9]{4})?$ //Validate Canadian postal code ^[ABCEGHJ-NPRSTVXY]{1}[0-9]{1}[ABCEGHJ-NPRSTV-Z]{1}[ ]?[0-9]{1}[ABCEGHJ-NPRSTV-Z]{1}[0-9]{1}$ //Grab unclosed img tags <img([^>]+)(\s*[^\/])> //Find all CSS attributes \s(?[a-zA-Z-]+)\s[:]{1}\s*(?[a-zA-Z0-9\s.#]+)[;]{1} //Get code within <?php and ?> <\?[php]*([^\?>]*)\?>