I.T. Discussion Community!
-Collapse +Expand
Coder
Search Coder Group:

Advanced
-Collapse +Expand Coder Study Test
PRESTWOODCERTIFIED
-Collapse +Expand Coder Store
PRESTWOODSTORE

Prestwood eMagazine

December Edition
Subscribe now! It's Free!
Enter your email:

   ► KBProgramming   Print This     
  From the April 2010 Issue of Prestwood eMag
 
Coder Programming:
Regular Expressions Cheat Sheet
 
Posted 11 years ago on 8/28/2008 and updated 10/6/2008
Take Away:

A collection of regular expressions that validate and parse common user data.

KB101300

Here I plan to store a collection of regular expressions that validate and parse common user data. Regular Expressions, though outside of the normal Delphi/Paradox mindset, are too powerful a tool to toss in the dustbin.

*This article will grow over time and show some examples, but for now I'm just storing a few expressions that I use from time to time.

*Example code will go here*

 

Validate that the input is one of the 50 US States

(:?A[KLRZ]|C[AOT]|D[CE]|FL|GA|HI|I[ADLN]|K[SY]|LA|M[ADEINOST]|N[CDEHJMVY]|O[HKR]|P[AR]|RI|S[CD]|T[NX]|UT|V[AIT]|W[AIVY])

 

Remove html markup

<(.|\n)*?>

Dates

(\d{1,2}\/\d{1,2}\/\d{4})

jpg, gif or png

([^\s]+(?=\.(jpg|gif|png))\.\2)

Hex or Color Code

(#?([A-Fa-f0-9]){3}(([A-Fa-f0-9]){3})?)

Email Address

(\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,6})

MORE INFO HERE

http://www.windowsdevcenter.com/pub/a/oreilly/windows/news/csharp_0101.html

If you have some to add, please add them below. I'd love to see them.

More Info

KB Post:  Regex

Comments

0 Comments.
Share a thought or comment...
 
Write a Comment...
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1162A1
Enter key:
KB Post Contributed By Bryan Valencia:

Bryan Valencia is the author of millions of lines of code and writes for PrestwoodBoards and Visual Studio Journey on-line magazines.

Visit Profile

 KB Article #101300 Counter
4164
Since 8/28/2008

Follow PrestwoodBoards on: 


©1995-2019 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech