Possible Duplicate:
Regular expression for parsing mailing addresses
I need to split a street address that will have one of two forms.
12B Main Road Main Road 12B
(all parts are optional)
I need to split into street name(Main), street type(Road, already have a list of possible street types), street number (12) and the street number suffix(B).
Any advice?
Will be doing this in C#.
considering that I don’t know all of the details(how you can expect roads to be formatted), this question is very hard to answer, but I’ll do what I can.
for your 2 specific examples, you can have
@"([\d|A-Z]*) ([A-Z|a-z| ]*) ([A-Z|a-z]*)"will match the order of your first answer
@"([A-Z|a-z| ]*) ([A-Z|a-z]*) ([\d|A-Z]*)"will match your second answer.
example:
output from that program looks something like the following
Use the Regex Cheat Sheet for information on how you can modify this.