Text file parsin - Separate State and Zip

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bombay59
    New Member
    • Jul 2007
    • 2

    Text file parsin - Separate State and Zip

    I have a text file with the fields such as as follows:

    "name", "age", "profession ", "street", "city", "statezip"

    For example:

    "joe", "24", "nurse", "1234 Coffee Lane", "Fremont", "CA94555"

    I would like to split the last field ("ca94555") so that the output file reads as follows:

    "joe", "24", "nurse", "1234 Coffee Lane", "Fremont", "CA", "94555"

    I know how to process the text but don;t know how to split any field.

    Any help will be appreciated.

    -Vic
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    next time post the code you have written so far:


    Code:
    $field = 'CA94555';
    my ($state,$zip) = $field =~ /^([a-zA-Z]+)(\d+)$/;

    Comment

    • bombay59
      New Member
      • Jul 2007
      • 2

      #3
      Thanks Kevin for your help. I will test my script an post the results.

      -Vic

      Comment

      Working...