develooper Front page | perl.beginners | Postings from May 2012

Regex behavior in command line

Thread Next
From:
Jon Forsyth
Date:
May 31, 2012 10:23
Subject:
Regex behavior in command line
Message ID:
CACv13pqht=sm1Fgpo5uwYmmv04yCX8kpYR85wr6jh5-qa9pqrQ@mail.gmail.com
Hello,

I'm using the following line in Terminal, on OSX Lion, but I can't seem to
match parentheses '()':

perl -n -e 'print if(/\\(Submit\\)/)' visits/admin_add.ctp

I tried with one backslash in front of each '(' ')' as well to no avail.
 If I remove the '\'s and '()' the match is printed like so:

<?php echo $form->end('Submit');?>

My purpose is to make sure I'm matching the correct lines including the
'()', then to alter the code to perform a search and replace on the
matches).   Something like:

perl -p -i.bak -e 's/PATTERN/REPLACE/g' INPUT

Thanks!

Jon


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About