PHP 1, PERL & SED 0

So I have been trying to figure out how to get PERL and SED to replace a set of random characters in a line with a fixed set of characters. I tried for about 2 days on Perl and sed, but could not get it to work right. So last night I tried PHP and got it in one shot. So say I have a file that has a part of a line that looks like this:

Variable1=test&Variable2=test%2312&Variable3=92ns10i9js

and I want to replace what ever is in the Variable2 value to be just a bunch of X’s or some other fixed value. Nothing I could do in sed and Perl would work, I ended up with this in PHP:

$buffer2=ereg_replace(“&Variable2=(.*)&Variable3″,”&Variable2=XXXXXXXX&Variable3”,$buffer);

So can any one tell me how to do it in Perl or sed?

One Reply to “PHP 1, PERL & SED 0”

  1. s/1=test.*Variable3/1=testXXXXXXXXXX\&variable3/

    Variable1=test&Variable2=test%2312&Variable3=92ns10i9js

Comments are closed.