in reply to Re^2: Parsing/manipulating CSV files
in thread Parsing/manipulating CSV files
And so on are universal. It is a vast area and easy to get lost in. But absolutely invaluable for data parsing. Baby steps and you will indeed get there! OK - so the postcode isn't in a predictable place. I assume it is in a predictable format that won't match anything else in a record?\d - matches 0 .. 9 (\d+) - means match at least 1 digit, could be more. [^ ] - means don't match space \S - Another way to match something that isn't a space
The ',?' bit means maybe match a comma ahead of the postcode. This is to catch the case that the pc is at the start of the record.$line =~ /,?([A-Z]{3}\d{2}[A-Z]),/;
|
|---|