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)
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";
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 section
brgdotnetcontractorAuthor Commented:
Thank you for the help. Not quite what I wanted, but thanks
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.