Return to Snippet

Revision: 25476
at April 14, 2011 05:14 by vagrantradio


Updated Code
//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]*([^\?>]*)\?>

Revision: 25475
at March 31, 2010 08:42 by vagrantradio


Initial Code
//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]*([^\?>]*)\?>

Initial URL

                                

Initial Description

                                

Initial Title
Useful regular expressions

Initial Tags
regex

Initial Language
Regular Expression