Regular expression question

From: ChocMonk (wolf_gore_at_yahoo.com.au)
Date: 01/31/05


Date: 30 Jan 2005 17:26:26 -0800

Hello,
I have an array with contents as below (from a VB project file):
my @objs= ("Object={831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0;
mscomctl.ocx\n",
"Object={31B58EFA-5E2E-4651-9454-2227ABB82B62}#6.7#0;
GridControls.ocx\n",
"Object={B9AA5EAF-A9B4-11D5-96CA-0010A4B15184}#1.0#0;
CompanyLogo.ocx\n",
"Object={BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0; tabctl32.ocx\n",
"Object={CA8A9783-280D-11CF-A24D-444553540000}#1.3#0; pdf.ocx\n",
"Object={64EE12AF-3495-45BC-AC02-43C29DF43376}#9.1#0;
StandardControls.ocx\n",
"Object={86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0; mscomct2.ocx\n");

I populated the array from parsing a file with the following regexp:
my @objs = grep(/^Object=\{\w|\-*\}#\d+\.\d+#\d?; .+/,@str);

Now I'm cycling through the array trying to split it up such that for
the first string in the example above I get the following values:
my $crap = "Object="
my $guid ="{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}"
my $ver = "2.0"
my $rev = "0"
my $name = "mscomctl.ocx\n"

I tried the following which doesn't work:
for (@objs) {
chomp;
(my $crap, my $guid, my $ver, my $rev, my $name) =
/(^Object=)(\{\w|\-*\})#(\d+\.\d+)#(\d?); (.+)/;
}

WHat am I doing wrong? I thought clustering the subexpressions will
capture what I want..

Thanks!
Choc



Relevant Pages

  • Re: Regular expression question
    ... ChocMonk wrote: ... > I have an array with contents as below (from a VB project file): ... > I populated the array from parsing a file with the following regexp: ... > the first string in the example above I get the following values: ...
    (comp.lang.perl.misc)
  • Re: Finding values (text,numbers, regexps) in objects (arrays or key/value pairs)
    ... for (var prop in objectPattern) { ... function matchArray(arrayPattern, array) { ... arrays to strings and then match with a regexp). ...
    (comp.lang.javascript)
  • Re: Regexp as constraint on random string generator
    ... conforming to a certain pattern. ... easily described using a regexp, and it crossed my mind to ... the random construction of a string. ... beginning, and the array. ...
    (comp.lang.tcl)
  • Re: Splat array with 1 value in Ruby 1.9 vs Ruby 1.8
    ... allow to pass a parameter "x" to the method var()) ... an Array with any number of elements. ... Now if you argue that you want to use the same regexp in both cases, that's not too difficult: both methods can share the regexp. ... def m1 ...
    (comp.lang.ruby)
  • Re: Weird regexp problem
    ... What's in @array here? ... I'm still not clear what makes you think this is a regexp problem. ... MySQL executes the exact query as it receives from Perl. ...
    (comp.lang.perl.misc)