regexp catching variable number of name=value fields?

Discussion in 'Perl Misc' started by Bruno Boettcher, Aug 28, 2003.

  1. Hello,

    i have a configuration file where i am slowly migrating to XML like
    notation (tryed XML::parser, but that one doesn't suit well into the
    rest of my program which uses OO design...). So since the stuff is
    stills simple, i throught i catch it with a normal regular
    expression... but as it seems i dont get something...

    the lines it has to catch are all XMl like, means
    <someenv arg1="toto" arg2="titi"/> there should allways be arguments.

    setup the following:

    if(open(STATFILE,"$ENV{HOME}/.config"))·
    {
    while(my $line = <STATFILE>)
    {
    chomp;
    if(index($line,'#') >=0 )
    {
    $line = substr($line,0,index($line,'#'));
    }# if(index($line,'#') >=0 )

    if($line && $line =~ /=/)
    {
    »·······#clean up to have a consistent state
    »·······$line =~ s/\s+=/=/g;
    »·······$line =~ s/=\s+/=/g;
    »·······my @matches = ($line =~ /(\S+=".*?")*/);
    »·······print("dumping args:".Dumper(\@matches));
    }# if($line && $line =~ /=/)
    }#while(<STATFILE>)
    close(STATFILE);
    }# if open STATFILE

    now this thing gives me back only the first match (the first argument),
    and i am wondering where the others went???

    any hint welcome


    --
    ciao bboett
    ==============================================================

    http://inforezo.u-strasbg.fr/~bboett
    Bruno Boettcher, Aug 28, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bobby Chamness
    Replies:
    2
    Views:
    2,378
    Joe Smith
    Apr 22, 2007
  2. mfglinux
    Replies:
    11
    Views:
    682
    Roberto Bonvallet
    Sep 12, 2007
  3. Joao Silva
    Replies:
    16
    Views:
    341
    7stud --
    Aug 21, 2009
  4. Replies:
    0
    Views:
    271
  5. Dominic

    JSON name/value name as number

    Dominic, Jun 10, 2010, in forum: Javascript
    Replies:
    3
    Views:
    66
    Dominic
    Jun 11, 2010
Loading...

Share This Page