RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Expressions by User

   Displaying page 1 of 1 pages; Items 1 to 4
Title Test Details First Name(s) OR Last Name(s)
Expression
^((?:[A-Z](?:('|(?:[a-z]{1,3}))[A-Z])?[a-z]+)|(?:[A-Z]\.))(?:([ -])((?:[A-Z](?:('|(?:[a-z]{1,3}))[A-Z])?[a-z]+)|(?:[A-Z]\.)))?$
Description
I wrote this regex to validate first names or last names separately. Allows for 2 names separated by space or hyphen. Will accept an abbreviated second name with period. Has to start with a letter and end with a letter or capital letter with period. Updated 3/24/2005: Now, names like McDonald work. Also, several convenient parts of the match are stored, for example: the Name MacDonald-O'Brian will yield the following: $1="MacDonald" $2="ac" $3="-" $4="O'Brian" $5="'"
Matches
O'Grady-Smith | Rachel Ann | McDonald T.
Non-Matches
Timothy J | James Earl Jones | @#$!*!
Author Rating: Not yet rated. Timothy Dutton
Title Test Details Capitalize Title
Expression
s/\b(\w+)\b/ucfirst($1)/ge
Description
I had some mailing contacts in a text file in mailing lable layout, and needed to extract them to database I used this regex to fix capitalization for name and address. THE JIM thomas FAMILY becomes The Jim Thomas Family
Matches
THE JIM THOMAS FAMILY
Non-Matches
!@#$%
Author Rating: Not yet rated. Timothy Dutton
Title Test Details Extract Mailing Lables to Database
Expression
\s*([a-z\. ]+)\s*\n\s*([a-z0-9\. #]+)\s*\n\s*([a-z \.]+)\s*,\s*([a-z \.]+)\s*\n?(?:\s*(\d{1,15}(?:-\d{1,4})?)\s*\n)?(?:\s*(\+?(?:1\s*[-\/\.]?)?(?:\((?:\d{3})\)|(?:\d{3}))\s*[-\/\.]?\s*(?:\d{3})\s*[-\/\.]?\s*(?:\d{4})(?:(?:[ \t]*[xX]|[eE][xX][tT])\.?[ \t]*(?:\d+))*))?
Description
View the description correctly formatted here: http://www.perlmonks.org/?viewmode=public;node_id=471216
Matches
See Description
Non-Matches
Won't match most non-word characters in name line, Fairly Permissive with phone number
Author Rating: Not yet rated. Timothy Dutton
Title Test Details Password
Expression
^(?=.*[\d])(?=.*[A-Z])(?=.*[a-z])[\w\d!@#$%_]{6,40}$
Description
Password must be 6-40 characters - {6,40} Must have no spaces, at least 1 digit (?=.*[\d]), at least 1 uppercase letter (?=.*[A-Z]) and at least one lowercase letter (?=.*[a-z]). Allows specifying special characters - !@#$%_
Matches
Pa5$Word | HORS3y | Th1$IsMyR3allYl0ngPa$$
Non-Matches
PASSWORD | password | Password | 1234567
Author Rating: The rating for this expression. Timothy Dutton
   Displaying page 1 of 1 pages; Items 1 to 4

Copyright © 2001-2024, RegexAdvice.com | ASP.NET Tutorials