in reply to Abritrary multiple spaces as delimiter
A simple regex won't work, as it would have to know the difference between "two spaces between words" and "two spaces at the end of the first part". You could either claim that "two or more spaces" delimit the items, but that will fall down as soon as you have one item that has the maximum allowed length. You could use a limited-length match like the following:
# 122 Genesis Chamber Mark Tedin A +U $string =~ /^(\d+)\s{2,}(.{28})(.{26})(.)\s+(.)$/;
But that is a very tedious way of constructing and using a regular expression when unpack can do the same:
my ($num,$title,$author,$flag1,$flag2) = unpack "A8A27A26A7A",$str;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Abritrary multiple spaces as delimiter
by Aristotle (Chancellor) on Mar 15, 2004 at 10:44 UTC |