in reply to Re: string matching/replacing
in thread string matching/replacing

How about something like this?

$chars will just contain a list of those you want to expose, everything else is converted to an asterisk or what ever you want. You may want to keep an original as I did with $info. Then use something like $known to expose the letters as desired. Notice, I included a space in the reveal chars to match your example.

I hope this helps :-)

#!/usr/bin/perl -w use strict; my $info = "I am a brown icecube"; my $chars = 'a '; my $known = $info; $known =~ s/[^$chars]/\*/g; print "$info\n"; print "$known\n";