Archive for category Regex

Validating password complexity with Regular Expression

Regex has always been one of those things that just never sticks in my mind, so imagine my horror when i found i had to adapt an existing regex we have for validating passwords for users who are creating accounts.  However I found a handy article explaining regex validation for password’s.

In this third example:

* Must be at least 10 characters

* Must contain at least one one lower case letter, one upper case letter, one digit and one special character

* Valid special characters are – @#$%^&+=

^.*(?=.{10,})(?=.*d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).*$

As you can see in the regex, the list of special characters is configurable.

via Password Validation via Regular Expression « Nilang Shah.

No Comments

Tools – Roy Osherove – Regulazy!

Just found an awesome tool allowing Regex noob’s such as myself, to build up Regex patterns, using only the sample data that you wish to match- go download Regulazy here!

Tools – Roy Osherove – Team Leadership, Agile Development & .NET – Speaking, Consulting, Training and Tools.

No Comments

Some handy Regular Expressions

Some handy regex patterns for grabbing different bits of gubbins and stuff;

EmailAddress:
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$

Postcode:
^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][ABDEFGHJLNPQRSTUWXYZabdefghjlnpqrstuwxyz]{2}$

HTML Tags:
<(.|\n)*?>

HTML Tags except for the BR tag:
(\<)(?!br(\s|\/|\>))(.*?\>)

No Comments