JD Vangsness
JD Vangsness

Reputation: 697

RegEx - find and replace string

i am trying to search my server and find the following in any files.

my regex grep -H -r '/\<\?php\spreg_replace\(\"\/\.\*\/e\"\,\.*?\)\;\?\>/gi' /var/www/html/optinsmart/

i'm looking for this <?php preg_replace("/.*/e"anything in here);?> and i want to replace it with nothing or just simply remove it.

it isn't returning any matches at the command line

but when i do grep '<?php preg_replace("/.*/e"' /var/www/optinsmart/ it returns all of them

is there something wrong in my regex?

EDIT

i am trying to find <?php preg_replace("/.*/e"???);?> where ??? could be anything.

Upvotes: 1

Views: 544

Answers (1)

anubhava
anubhava

Reputation: 785146

You can use grep -F (fixed string without regex):

grep -FHr '<?php preg_replace("/.*/e"' *

To delete these line use this sed:

sed -i.bak '/<?php preg_replace("\/.*\/e"/d' *

Upvotes: 1

Related Questions