I'm creating a workflow that takes data from a form and pushes it to a sql database. The problem is that the form captures the address as one line while the database breaks it out into sections ("StreetNumber" "Direction" "StreetName" "StreetType"). I know very little about regular expressions, but I've managed to separate all but the street name. Any help would be appreciated
Question
Question
Replies
What does your form look like? I assume you are submitting a form and calling a workflow and that workflow updates SQL? I would use the built in address field or make single lines for each portion of the address you wish. If your address field is one line on your form, I don't believe you could use regex to account for all the possible ways a user could not fill out that line correctly (out of order, missing info, etc).
This is the address section on the form.
Then in workflow, when you do a Retrieve Business Process Variables, each line should appear as its own token and you should be able to use them for your insert
I'm trying to pull only the street name from the address line.
What they type: 1222 North Sandish Lane
What I want: Sandish
Can you guarantee the pattern? \d*\s.*\s(.*)\s will get you Sandish out of that string. But is there a Sandish Lane (no North). Or 123 Elm, or 5544 Highway 12 North.
Maybe someone better at regex can chime in but can you guarantee that the name you want is always the 'second word after the number'? Could it be the first or third?
No, the street name can be the third word in the pattern
Addresses are not really all that regular and so regular expressions do not work that well. You end up having to build a bunch of different expressions ORed together to handle each case you can think of but there will still be data that is not handled by any case you included.
You can have all sorts of un-regular things like:
A prefix to the number - for instance PO
A hyphenated or fractional building number - 123 1/2 A St
An optional direction/location - can be before or after the street name or both
The above are just a few samples of the may things that make processing addresses difficult. Then you also have things like N or North can be a direction/location or it could be the street name. In "216 North Haven Rd W", is North Haven the the street or is it Haven with a direction/location prefix?
If you search the internet for address regular expressions, every answer starts by trying to tell you it is going to take a lot of your time and it will not be perfect.