in reply to Set condition values with regex.
Try this:
#! perl use strict; use warnings; use Data::Dump; my $s = q[{name eq \'Apple, Tomato, Orange\'}]; if ($s =~ /^\{(\w+)\s+(\w+)\s+\\'(.*)\\'\}$/) { my @array = split /,\s*/, $3; print "name: $1\n"; print "condition: $2\n"; print 'array: '; dd @array; } else { print "No match found\n"; }
Output:
1:16 >perl 559_SoPW.pl name: name condition: eq array: ("Apple", "Tomato", "Orange") 1:17 >
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Set condition values with regex.
by huchister (Acolyte) on Mar 05, 2013 at 16:03 UTC |