in reply to Split using multiple conditions
Personally, I'd be inclined to use the dual approach: match the stuff between brackets, or nonspaces.
$_ = 'FDR [62.10060.051-F] [62.10051.381] [this includes spaces!] 0 1 +0'; @parts = /\[.*?\]|[^\[\]\ ]+/g; $\ = "\n"; print for @parts;
Yes it can be that compact. Result:
FDR [62.10060.051-F] [62.10051.381] [this includes spaces!] 0 1 0
A limitation is that you can't easily split on single spaces, thus returning empty strings as a section.
|
---|