in reply to Split unless contained by
You needn't use split(). A regex is sufficient:
my $str = "foo|{baz|qux}|fax"; my @parts = $str =~ /( \{.+?\} # e.g., {baz|qux} | [^|]+ # e.g., foo ) (?:\||$) # |, or end of string /xg; $" = "\n"; print "@parts"; __END__ foo {baz|qux} fax
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Split unless contained by
by Ferret (Scribe) on Aug 09, 2002 at 23:40 UTC | |
|
Re: Re: Split unless contained by
by BUU (Prior) on Aug 10, 2002 at 01:55 UTC |