regex - ignore special characters in find and replace command of perl -



regex - ignore special characters in find and replace command of perl -

i using command perform find , replace

system( "perl -pi -e 's/$arr3[$i]/$arr2[$i]/g' /opt/app/d1ebl1m5/dv02/cingbt02/j2eeserver/config/amss/application/properties/cscenvvar.properties_try");

the value of $arr3[$i] contains special characters -e, $ etc. can ignore special characters , treat look normal string

you want

my $search_pat = quotemeta($search); s/\q$search_pat\e/$replace/g

or equivalent

s/\q$search\e/$replace/

it's bad thought generate code, solution becomes

system( perl => ( '-i', '-p', '-e' => ' begin { $s = shift(@argv); $e = shift(@argv); } s/\q$s/$e/g ', '--', $arr3[$i], $arr2[$i], '/opt/app/.../cscenvvar.properties_try', ) );

regex perl replace

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -