Escape wildcard in Perl

Home > Search

Let's say you've a string of data that contains the wildcard character.

my $foo = "b*r";


Printing foo will display the wildcard. 

print "$foo\n";


Remove the wildcard character

If you do not need the wildcard character, it probably makes sense to just remove the wildcard character all together. This removes the wildcard character from $foo.

$foo =~ s|\*||;


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter in the box below so that we can be sure you are a human.