RegEx variable isolation

Discussion in 'Perl Misc' started by coffeevictim, Dec 1, 2006.

  1. coffeevictim

    coffeevictim Guest

    Hi,

    I have an incorrect regex which seeks to add a column to a CSV file.
    The new column always contains a "1" and is always the second to
    last column.

    My problem is that I don't know how to isolate the $1 from the 1 that
    follows it so in my attempt it just looks like $11. Can anyone help?

    $SOURCELINE =~ s/(.*,)$2/$11,$2/;

    Thanks

    coffeevictim
     
    coffeevictim, Dec 1, 2006
    #1
    1. Advertising

  2. coffeevictim

    Mirco Wahab Guest

    coffeevictim wrote:

    > My problem is that I don't know how to isolate the $1 from the 1 that
    > follows it so in my attempt it just looks like $11. Can anyone help?
    >
    > $SOURCELINE =~ s/(.*,)$2/$11,$2/;
    >


    $SOURCELINE =~ s/(.*,)/${1}1,/;

    Regards

    M.
     
    Mirco Wahab, Dec 1, 2006
    #2
    1. Advertising

  3. coffeevictim

    coffeevictim Guest

    Mirco Wahab wrote:
    > coffeevictim wrote:
    >
    > > My problem is that I don't know how to isolate the $1 from the 1 that
    > > follows it so in my attempt it just looks like $11. Can anyone help?
    > >
    > > $SOURCELINE =~ s/(.*,)$2/$11,$2/;
    > >

    >
    > $SOURCELINE =~ s/(.*,)/${1}1,/;
    >
    > Regards
    >
    > M.


    Cheers M.

    cofffeevictim
     
    coffeevictim, Dec 1, 2006
    #3
    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. Jesper
    Replies:
    1
    Views:
    1,959
    Guenther Liebowitz
    Aug 14, 2003
  2. =?Utf-8?B?Sm9obiBNY0d1aXJl?=

    ASP.Net Performance better with IIS 6.0 in IIS 5.0 isolation mode

    =?Utf-8?B?Sm9obiBNY0d1aXJl?=, Apr 14, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    723
    Alvin Bruney [MVP - ASP.NET]
    Apr 15, 2005
  3. Replies:
    1
    Views:
    980
  4. Replies:
    0
    Views:
    412
  5. Andrew
    Replies:
    3
    Views:
    413
    Goran Sliskovic
    Oct 8, 2003
Loading...

Share This Page