Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
This pattern could appear many time in the string, a multiple element string would appear as:data_element::item::value|item::value|item::value
The only constant is the placement of the "::" and the "|". Below is some code that I've tested with (without success):date0_element::item::value|item::value|item::value|data1_element::item +::value|item::value|item::value
What I would expect (and desire) would be seperate values for each data set instance as below:#!/usr/bin/perl $_="monsa::clear::1|red::23|blue::50|monsb::clear::80|red::90|blue::10 +0|"; @instances = m/(\S+::\S+::\S+\|\S+::\S+\|\S+::\S+\b)/g; foreach $inst (@instances) { print "found $inst\n"; } exit;
But it seems to throw everything into one array value. Any thoughts?monsa::clear::1|red::23|blue::50 monsb::clear::80|red::90|blue::100
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regular Expression Trick
by sgifford (Prior) on Nov 24, 2003 at 06:07 UTC | |
|
Re: Regular Expression Trick
by Roger (Parson) on Nov 24, 2003 at 06:14 UTC | |
|
Re: Regular Expression Trick (Don't use one!)
by dragonchild (Archbishop) on Nov 24, 2003 at 13:29 UTC | |
by duff (Parson) on Nov 24, 2003 at 15:08 UTC | |
|
Re: Regular Expression Trick
by Anonymous Monk on Nov 24, 2003 at 06:03 UTC |