Gossamer Forum
Home : General : Perl Programming :

Search and replace using tr//c

Quote Reply
Search and replace using tr//c
I've been playing around with this bit, but can't quite seem to get the last part right.

$checkit = "tony!|bob&sue|me@me.com";

$checkit =~ tr/[A-Za-z0-9][ ][.][|]/\*/c;

I've got it matching all non-character, non-numeric (except for space, period and pipe).

I want to replace the non-items with a backslash and the non-item. (tony\!|bob\&sue|me\@me.com).

I can't seem to figure out what to use where the * is in the tr// bit. I tried $1 (and about 6 million other things) but that didn't work.

Any suggestions?

Last edited by:

Watts: Dec 15, 2003, 2:11 PM
Subject Author Views Date
Thread Search and replace using tr//c Watts 5698 Dec 15, 2003, 2:10 PM
Thread Re: [Watts] Search and replace using tr//c
Coombes. 5591 Dec 15, 2003, 4:19 PM
Thread Re: [Coombes.] Search and replace using tr//c
Watts 5572 Dec 16, 2003, 7:59 AM
Post Re: [Watts] Search and replace using tr//c
Coombes.. 5565 Dec 16, 2003, 8:54 AM