#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Pune, Maharashtra, India
    Posts
    86
    Rep Power
    14
    I have a file called temp which has something printed like this:
    # goods #
    blah blah
    blah blah
    };
    # bad.com #
    blah blah
    blah blah
    };
    I want a script that searches the # goods # and deletes everything from their till just before the line # bad.com #. But i am not able to do so till now any help will be highly appreciated.
    The biggest problem is that between two number of lines may defer and what is wriiten may also defer.
    Thanks for your help.


    ------------------
    Nikunj Virani
    MYSQL/PHP/XML
    This is the world of Nikunj
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Pune, Maharashtra, India
    Posts
    86
    Rep Power
    14
    This is myfile i want that all the instances from # idiot.com # to the line before # goodboy.com # should be deleted i.e any thing between # xy.com # till # yz.com # should be removed whatever it is any help will be highly appreciated.
    # idiot #
    zone "idiot.com" {
    type master;
    file "idiot.com";
    };
    # goodboy.com #
    zone "goodboy.com" {
    type master;
    file "goodboy.com";
    };

    ------------------
    Nikunj
    MYSQL/PHP/XML
    ** Expertise comes with experiece ** Nikunj
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    32
    Rep Power
    14
    $filename = "file.txt";
    $text = join("n",file($filename));
    $startingexp = "# idiot #";
    $endingexp = "# goodboy.com #";
    $text = preg_replace("/$startingexp+?[wW]+?$endingexp/","",$text);


    This will replace the $endingexp variable in addition to everything between it. If you do not want that, then make another marker right before # goodboy.com # that can be deleted and set that as $endingexp. Hope that helps (and works - I haven't actually tested it).
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Pune, Maharashtra, India
    Posts
    86
    Rep Power
    14
    What does this wW means in the expression.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    32
    Rep Power
    14
    W stands for white space - it matches any white space
    w is exactly the opposite - it matches everything except a white space

    by doing [wW] you match any character, white space or not white space -

Similar Threads

  1. sendmail installation problem on Linux
    By abuschr in forum Linux Help
    Replies: 0
    Last Post: January 14th, 2004, 09:08 AM
  2. removing openssl rh9
    By odave in forum Linux Help
    Replies: 0
    Last Post: January 11th, 2004, 10:51 PM
  3. IMAP Install issue
    By Sillysoft in forum Mail Server Help
    Replies: 5
    Last Post: December 11th, 2003, 01:52 AM
  4. PHP upgrade issues, plz help
    By justinm99 in forum PHP Development
    Replies: 1
    Last Post: October 23rd, 2003, 03:30 PM
  5. Problems installing mod_perl 1.2.7 with perl 5.8.0
    By cptsanity in forum Perl Programming
    Replies: 7
    Last Post: February 20th, 2003, 07:49 AM

IMN logo majestic logo threadwatch logo seochat tools logo