Please help with regexp - finding all matches?

From: Boris Pelakh (pelakh_at_yahoo.com)
Date: 04/08/04


Date: 8 Apr 2004 06:35:58 -0700

I'm trying to extract name:value pairs from a string similar to this one

{a:b,c:d,e:f}

The individual pieces are more complicated, but its similar in principal

Here is a test script I use

$f = "a:b,c:d,e:f";
@a = ($f =~ m/(?:(\w+):(\w+))(?:,(?:(\w+):(\w+)))+/);
print "@a\n";

I should be seeing "a b c d e f", but I am only getting "a b e f",
i.e. the first and last group matched. Why am I not seeing the rest?
Ideally I want to just assign the result of the match to a hash.

-- Boris



Relevant Pages

  • Re: Extract part of a string
    ... I want to extract everything between the hash signs in the following ... Paul Lalli ...
    (perl.beginners)
  • Re: array to string conversion
    ... # Assuming my hash: ... # I need to extract the values in each array with the extentions(values ... # periods) into another string. ...
    (comp.lang.ruby)
  • Re: array to string conversion
    ... I now encounter another problem.. ... # I need to extract the values in each array with the extentions(values ... # periods) into another string. ... Assuming I have my hash: ...
    (comp.lang.ruby)
  • Re: HoHoH (hash of HoHs)
    ... >> I have a file that contains either a hash, or a HoH on each line. ... > A text file doesn't contain hashes, ... I extract them using the 'eval' function on ... > To collect the resulting hashes in another hash, you need a key (a string) ...
    (comp.lang.perl.misc)
  • Re: How to write a diff in VB6 for comparing two xml files?
    ... No, the best you could do is to read both into string and use StrCompbut it's inefficient and, but using the hash ... Private Declare Function CryptAcquireContext Lib "AdvAPI32.dll" Alias _ ... Dim HashAAs Byte, HashLenA As Long ...
    (microsoft.public.vb.general.discussion)