Help with regular expression for a physical address

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)
LVL 2
brgdotnetcontractorAsked:
Who is Participating?
 
Terry WoodsIT GuruCommented:
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
 
brgdotnetcontractorAuthor Commented:
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
 
brgdotnetcontractorAuthor Commented:
Thank you for the help. Not quite what I wanted, but thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.