Grep Escaping

Discussion in 'Programming' started by glasglow, May 19, 2010.

  1. #1
    How do I escape this with / please?

    <?php /**/ ());?>

    It seems every time I try to find it with grep, it won't find it because of the quantifiers themselves..
     
    glasglow, May 19, 2010 IP
  2. Fervid

    Fervid Well-Known Member

    Messages:
    161
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    120
    #2
    <?php \/\*\*\/ ());?>
     
    Fervid, May 19, 2010 IP
  3. glasglow

    glasglow Active Member

    Messages:
    926
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Not yet. Here's what I have: Sorry change to a grep to a find-perl:

    find //dir "*.php"|xargs perl -w -i -p -e "s/<?php \/\*\*\/ ());?>//g"

    Then I get error:

    Unmatched ) in regex; marked by <-- HERE in m/<?php /\*\*/ ()) <-- HERE ;?>/ at -e line 1.
     
    glasglow, May 19, 2010 IP
  4. Fervid

    Fervid Well-Known Member

    Messages:
    161
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    120
    #4
    When it doubt, comment it all out. ;)

    \<\?php \/\*\*\/ \(\)\)\;\?\>
     
    Fervid, May 19, 2010 IP
  5. glasglow

    glasglow Active Member

    Messages:
    926
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #5
    No kidding.. Haha that's kind of funny. Can't get some of it, try it all. : ) Well, it worked. Thank you so very much.
     
    glasglow, May 19, 2010 IP
  6. Fervid

    Fervid Well-Known Member

    Messages:
    161
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    120
    #6
    I'm decent with regular expressions but sometimes it just doesn't work as I think it should. Usually I can correct the problem by escaping characters. As long as the characters you're escaping aren't being eval'd it's harmless to unnecessarily escape them. Like I said "When in doubt..." :D
     
    Fervid, May 20, 2010 IP