RosettaCodeData/Task/Regular-expressions/Perl/regular-expressions-4.pl

5 lines
144 B
Perl
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
$string = "I am a string";
if ($string =~ s/\bam\b/was/) { # \b is a word border
print "I was able to find and replace 'am' with 'was'\n";
}