Replace command not working

Viewed 456

I want to replace this code

 for($counter=0;$counter<10;$counter++)
 {
     $yyarr[$counter]=$counter+2004;
 }

with

 for($counter=2004;$counter<=date("Y");$counter++)
 {
     $yyarr[$counter-2004]=$counter;
 }

I am using

sed -e 's/for\(\$counter=0;\$counter<10;\$counter++\)\n\t+{\n\t+\$yyarr\[\$counter\]=\$counter+2004;\n\t+}/for\(\$counter=2004;\$counter<=date\("Y"\);\$counter++\)\n{\$yyarr\[\$counter-2004\]=\$counter;\n}/g'

But can't get it through. Trailing whitespace needs to be ignored.

2 Answers
Related