?
Solved

Help with regular expression for a physical address

Posted on 2009-04-28
3
Medium Priority
?
544 Views
Last Modified: 2012-05-06
I need a regular expression that will validate a physical address. (NOT EMAIL)
So like 222 Memory Lane #320

I want to avoid invalid special characters like ^$!*^= _ % ~ `
But keep these #,&, '   (That is single quuote is acceptable ex. 23 O'malley lane)
0
Comment
Question by:brgdotnet
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
Terry Woods earned 300 total points
ID: 24256766
Not sure the flavor of regex you're using, but a PCRE (Perl Compatible Reg Ex) that checks for invalid characters would be something like:

@^[a-z0-9 #,&.']*$@i

eg in php:

$pattern = '@^[a-z0-9 #,&.\']*$@i';
if (preg_match($pattern,$address)) {
  print "Address is valid";
}
0
 
LVL 2

Author Comment

by:brgdotnet
ID: 24256833
I sure do appreciate your help. It did not work for me. I am using ASP.NET . I will repost this message in the asp.net section
0
 
LVL 2

Author Closing Comment

by:brgdotnet
ID: 31575762
Thank you for the help. Not quite what I wanted, but thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Batuhan Cetin Regular expression is a language that we use to edit a string or retrieve sub-strings that meets specific rules from a text. A regular expression can be applied to a set of string variables. There are many RegEx engines for u…
We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question