simple perl regex question

Discussion in 'Perl Misc' started by Mirco Wahab, Aug 20, 2007.

  1. Mirco Wahab

    Mirco Wahab Guest

    wrote:
    > disclaimer - perl and shell scripting is not my area of expertise, but
    > I've been asked to help in updating a ton of DNS zone files. I've got
    > my scripts down to one last issue - updating the serial numbers in the
    > files.
    >
    > Basically, the serials are all 10 digt numbers followed by a ;
    >
    > I'm trying to write a regex to find 10 digits ([0-9]{10}), follwed by
    > a semi-colon ([;]) and then just replace it with 2007083100;
    >
    > Here's where I'm at - it runs ok, but the file isn't being updated:
    >
    >
    > perl -pi -e 's/\/([0-9]{10})([;])\//2007083100;/g' domain.com.db
    >
    > I think I'm close here - maybe?


    Yes, hairs width (imho):

    $> perl -i -pe 's/(?<!\d)\d{10}(?=\s+;)/2007083100/g' domain.com.db

    Regards

    M.
     
    Mirco Wahab, Aug 20, 2007
    #1
    1. Advertising

  2. Mirco Wahab

    Mirco Wahab Guest

    wrote:
    > Here's where I'm at - it runs ok, but the file isn't being updated:
    > perl -pi -e 's/\/([0-9]{10})([;])\//2007083100;/g' domain.com.db
    > I think I'm close here - maybe?


    Yes, hairs width (imho). But I've seen zone files with a \s in front
    of the ';' ...

    $> perl -i -pe 's/(?<!\d)\d{10}(?=\s*;)/2007083100/g' domain.com.db

    Regards

    M.
     
    Mirco Wahab, Aug 20, 2007
    #2
    1. Advertising

  3. Mirco Wahab

    Guest

    disclaimer - perl and shell scripting is not my area of expertise, but
    I've been asked to help in updating a ton of DNS zone files. I've got
    my scripts down to one last issue - updating the serial numbers in the
    files.

    Basically, the serials are all 10 digt numbers followed by a ;

    I'm trying to write a regex to find 10 digits ([0-9]{10}), follwed by
    a semi-colon ([;]) and then just replace it with 2007083100;

    Here's where I'm at - it runs ok, but the file isn't being updated:


    perl -pi -e 's/\/([0-9]{10})([;])\//2007083100;/g' domain.com.db

    I think I'm close here - maybe?
     
    , Aug 20, 2007
    #3
  4. Mirco Wahab

    Guest

    Wow - I need to read up on what some of that stuff does.

    Thank you - it works like a charm!!

    On Aug 20, 5:25 pm, Mirco Wahab <-halle.de> wrote:
    > wrote:
    > > Here's where I'm at - it runs ok, but the file isn't being updated:
    > > perl -pi -e 's/\/([0-9]{10})([;])\//2007083100;/g' domain.com.db
    > > I think I'm close here - maybe?

    >
    > Yes, hairs width (imho). But I've seen zone files with a \s in front
    > of the ';' ...
    >
    > $> perl -i -pe 's/(?<!\d)\d{10}(?=\s*;)/2007083100/g' domain.com.db
    >
    > Regards
    >
    > M.
     
    , Aug 20, 2007
    #4
    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. Rick Venter

    perl regex to java regex

    Rick Venter, Oct 29, 2003, in forum: Java
    Replies:
    5
    Views:
    1,693
    Ant...
    Nov 6, 2003
  2. Saad Malik
    Replies:
    5
    Views:
    402
    John C. Bollinger
    May 2, 2005
  3. Replies:
    2
    Views:
    630
  4. Replies:
    3
    Views:
    834
    Reedick, Andrew
    Jul 1, 2008
  5. Wladimir Borsov
    Replies:
    4
    Views:
    324
    Tintin
    May 11, 2006
Loading...

Share This Page