Replace variable length numeric string

I have a customer who logged some cc and bank account numbers in their apache logs. I got the cc numbers x'd out with

sed -e 's/args=[0-9]\{16\}/args=XXXXXXXXXXXXXXXX/g' -e 's/cardnum=[0-9]\{16\}/cardnum=XXXXXXXXXXXXXXXX/g'

but that wasn't too difficult due to the value being 16 digits.

The bank account info is different, might be 6 digits, might be 10, might be 15. The actual string in the log entry will contain

args=123456789&acctnum=123456789

somewhere in the middle of the line.

Now that I think about it, the new value doesn't have to match the original, meaning if it's a 7 digit value, I don't have to have 7 x's, I can replace the value, whatever the length, with say 7 or 10 x's. I'm just not sure how to identify the original variable length string.

Any thoughts?

> echo "args=123456789&acctnum=123456789"
args=123456789&acctnum=123456789

> echo "args=123456789&acctnum=123456789" | tr "[:digit:]" "X"
args=XXXXXXXXX&acctnum=XXXXXXXXX

sed -e "s/args.*acctnum.*/args=XXXXXXXXX&acctnum=XXXXXXXXX/g" file > file.out

or

perl -i -pe "s/args.*acctnum.*/args=XXXXXXXXX&acctnum=XXXXXXXXX/g" file

$ echo 'args=123456789&acctnum=123456789'|sed -e "s/args.*acctnum.*/args=XXXXXXXXX&acctnum=XXXXXXXXX/g"
args=XXXXXXXXXargs=123456789&acctnum=123456789acctnum=XXXXXXXXX

Man, thanks for the quick replies everyone. I haven't played with any of them yet, I will after this post. But I wanted to give you the entire picture, just in case it helps, sorry should have put this in the orig post.

Here is a single entry from the log (edited of course)

www.testsite.org 11.222.333.444 - - [02/Feb/2009:13:58:18 -0600] "GET /regrenew/pay.cgi?fname=complete_payment&args=John%20C.%20Doe&acctname=John
%20C.%20Doe&args=2468%20Jackson&acctaddress=2468%20Jackson&args=Miami&acctcity=Miami&args=FL&acctstate=FL&args=12345&acctzip=12345&args=111111111
&routing=111111111&args=2222222222&acctnum=2222222222&args=jdoe@email.net&acctemail=jdoe@email.net&args=999-999-9999&acctphone=999-999-9999 HTTP/
1.1" 200 1996 "https://www.testsite.org/regrenew/index.cgi" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 
2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; Windows-Media-Player/10.00.00.3990; Zune 3.0)"

I just need to x out this section

args=111111111&routing=111111111&args=2222222222&acctnum=2222222222

I need to keep all other entries, phone, address, zip, etc.

Again thanks a ton for the quick replies, I'm going to go test them now.

if the number of X-s doesn't have to match the number of the original digits:

sed 's#args=[0-9][0-9]*&routing=[0-9][0-9]*&args=[0-9][0-9]*&acctnum=[0-9][0-9]*#args=xxxxxxxx\&routing=xxxxxxxx\&args=xxxxxxxx\&acctnum=xxxxxxxx#' myFile

vgersh99!!

I started testing with the most recent posts and low and behold the last one from vgersh99 worked perfectly.

Many thanks to all of you for your efforts.
Vgersh99 if I could send you the beverage of your choice I would, but in this
medium you'll have to settle for a :b: :smiley:

Have a great day everyone!!

Sorry, my mistake, should have been:

sed -e "s/args.*acctnum.*/args=XXXXXXXXX\&acctnum=XXXXXXXXX/g"