Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Parse mailing addresses with a regex

by TomDLux (Vicar)
on Jun 23, 2003 at 14:33 UTC ( #268179=note: print w/replies, xml ) Need Help??


in reply to Parse mailing addresses with a regex

You might consider working backwards, or from the middle out, first extracting things you are more confident about. For example:

$line =~ s/\w*\s*[:upper:]{2}\s(\d{5}\s*(\d{3][-\s]*\d{3}-\d{4})\s*(.* +)$//; ($custCity, $custState, $custZip, $custTel, $custComments) =($1, $2, $ +3, $4, $5); $line =~ s/(\d*)\s*(.*)\s*(\d*.*)$/; ($custNum, $custName, $custStreet) = ($1, $2, $3);

This assumes that cities are one word, so it won't work if any of your customers are in New York City or Atlantic City or Boca Raton or Las Vegas.

--
TTTATCGGTCGTTATATAGATGTTTGCA

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://268179]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2021-03-02 01:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favorite kind of desktop background is:











    Results (33 votes). Check out past polls.

    Notices?