Here are some useful regex expressions for data generation in VSTS DB Pro

Published 03 December 06 05:52 PM | rfustino 

Thanks to Gert Drapers' blog: http://blogs.msdn.com/gertd/archive/2006/11/26/regex-is-your-friend.aspx

 

Simple gender representation:

  • (F)emale or (M)ale using a single character representation (F|M)
    • F|M
  • Mr or Mrs
    • Mr|Mrs

Various phone number formats:

  • Simple phone number formatted like 267-820-8446 (separated by dashes)
    • [1-9][0-9]{2,2}-[1-9][0-9]{2,2}-[0-9]{4,4}
  • Simple phone number formatted like (267) 820-8446
    • \([1-9][0-9]{2,2}\) [1-9][0-9]{2,2}-[0-9]{4,4}
  • Phone number within area code 425
    • 425-[1-9][0-9]{2,2}-[0-9]{4,4}
  • Phone number within area 425 or 206
    • (206|425)-[1-9][0-9]{2,2}-[0-9]{4,4}
  • Internal notation using country code 1 and area code 425 or 206
    • \+1 (425|206)-[1-9][0-9]{2,2}-[0-9]{4,4}

ZIP codes:

  • Simple ZIP code 5 digits plus 4 digits separated by a dash (like 98008-2405)
    • [1-9][0-9]{4}-[0-9]{4}
  • ZIP code that starts in area 98xxxx
    • 98[0-9]{3}
  • Add state to zip code like WA 98322-1001
    • WA 98[0-9]{3,3}-[1-9]{1,1}[0-9]{3,3}

 Address:

  • Create a simple address
    • [1-6]{1}[0-9]{1,3} (SE|NE|NW|SW) [1-2]{1}[0-9]{1,2}th (ST|CT|PL|AVE), (Redmond, WA 9805[0-9]|Bellevue, WA 9800[1-9]|Sammamish, WA 9807[0-9]|Seattle, WA 9806[0-9]|Issaquah, WA 9808[0-9])

City names:

  • List of city names
    • Seattle|(New York)|Boston|Miami|Beijing|(Los Angles)|London|Paris

First & last names:

  • List of first names
    • (Pete|Tom|Mary|Larry|Lisa|Brain|David|Jeff|Amy)
  • List of last names
    • (Johnson|Smith|Good|Anderson|Baker|Crawford)
  • List of name (first + last)
    • (Pete|Tom|Mary|Larry|Lisa|Brain|David|Jeff|Amy) (Johnson|Smith|Good|Anderson|Baker|Crawford)

E-mail addresses:

  • Simple email address
    • [a-z]{5,8}@(hotmail\.com|msn\.com|[a-z]{3,8}\.(com|net|org))

Social Security number:

  • [1-9][0-9]{2}-[0-9]{2}-[0-9]{4}

Credit card number:

  • [1-9][0-9]{3} [0-9]{4} [0-9]{4} [0-9]{4}

Credit card names:

  • AMEX|VISA|MASTER

Shippers:

  • DHL|FedEx|UPS

 

Comments

# jmanning said on December 3, 2006 10:06 PM:

Why the copy-paste from Gert's blog instead of linking to it, or at least mentioning it?

http://blogs.msdn.com/gertd/archive/2006/11/26/regex-is-your-friend.aspx

New Comments to this post are disabled

About rfustino

Russ wisely shelved dreams of rock and roll stardom in order to share his vast knowledge with developers nationwide. Given that he can’t sing or play an instrument, other than in Guitar Hero, we’re all very grateful. Russ has more than 25 years of software development. He’s the creator of the Russ' Tool Shed developer seminar series and has donned his trademark suspenders, hardhat and tool belt in presentations for over 75,000 developers at 1,700 events. Russ also has expertise in developing Visual Basic and Web-based solutions using Microsoft tools. Before joining Microsoft eleven years ago, Russ worked as a VB instructor, headed up a development department, and created several client/server applications and system software products. His specialties include development with VB.NET, XML Web services, ASP.NET, XNA, Silverlight, Development Tools and debugging. But make no mistake – Russ is not all brains. His big heart led him to establish Take a Swing at Cancer, Inc., a non-profit organization that holds softball and golf-based fundraisers to battle cancer. You have to know the code to get in the shed. KNOW THE CODE!

Search

This Blog

Tags

(Russ' Tool Shed and Tiki) MSDN Events

.NET Pub Club Videos

CTECs in the Gulf States

DE Blogs

Joe Healy

Other Microsoft Events

South East Region User Groups

Take a Swing at Cancer

Syndication

Page view tracker