in reply to Using perl to break up sentences in rows into Separate columns
Also, please, please, please, use some HTML tags to format your post
The second column looks pretty free form, but after it should be the word 'due'. Is this always the case? So, a regex something like this could work:
Now keep in mind that your problem statement is rather ambiguous, but i think that this regex will work for the sample data you provided.$line =~ /^( # start $1 \D+ # unit ind. (US$ for ex) \d+(?:\.\d+)? # the amount \s+ # whitespace [A-Z]+ # scale (mil for ex) ) # end $1 (.+) # $2 - the second part \sdue\s # literal word 'due' surrounded by spaces (.+) # $3 $/xi; my @columns = ($1, $2, $3)
You'll probably have to add tweaks for various additional possibilities, such as commas in the numbers. This also assumes that the word 'due' does not appear anywhere in the data that should be in the second column.
Anyway, this should get you started. Note i did not test my code.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using perl to break up sentences in rows into Separate columns
by thcsoft (Monk) on May 10, 2005 at 08:49 UTC | |
|
Re^2: Using perl to break up sentences in rows into Separate columns
by mariah (Initiate) on May 10, 2005 at 13:56 UTC | |
by shemp (Deacon) on May 10, 2005 at 16:56 UTC |