Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with this Regex replace... (easy?)

Status
Not open for further replies.

zackiv31

Programmer
May 25, 2006
148
US
I'm using Regexp::Common::profanity to filter out profanity from user submitted data... I want to replace all occurrences of profanity with the appropriate # of asterisks...

A four letter word ends up being: "****". Here's the start of what I have, but syntactically it's incorrect.

$noprof =~ s/$RE{profanity}/*{length($`)}/gi;


I think length($`) gives me the length of the match... but how do I repeat the asterisks length number of times?
 
$noprof =~ s/($RE{profanity})/'*' x length($1)/gie;
 
Looks like you figured it out. :)

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top