Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
now I want to test my string, $str, for any instinces of $badword. But I don't just want to leave it at that, I want to make sure I catch the silly little "b*a*d w&or-d" instinces. How would I check $str, for $badword with any non word characters between each character.... Basicly I want do do the following, but by using a string rather than literals....$badword = "badword";
how could I do that with an array of strings?$str =~ /(\bb\W*a\W*d\W*w\W*o\W*r\W*d\b)|badword/;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: using a string in a regexp
by frag (Hermit) on Jan 04, 2002 at 06:12 UTC | |
|
Re: using a string in a regexp
by gav^ (Curate) on Jan 04, 2002 at 08:10 UTC |