in reply to Split this string
my $string = <<HTML; this=x that=x x another=x thing=x HTML my @array = $string =~ /(?:^| )(.+?)(?=(?: \w+=|$))/g; print "[$_]\n" for @array; # whoops, was "[$_\n]" # prints: [this=x] [that=x x] [another=x] [thing=x]
Update: Corrected typo, per johngg below.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Split this string
by johngg (Canon) on Oct 12, 2011 at 13:44 UTC | |
|
Re^2: Split this string
by Lotus1 (Vicar) on Oct 12, 2011 at 14:43 UTC | |
|
Re^2: Split this string
by Anonymous Monk on Oct 12, 2011 at 14:14 UTC |