Regex Operators

Learn about the use of different regex operators in Perl.

Match and binding operators

A regex can be as simple as a substring pattern:

Press + to interact
my $name = 'Chatfield';
say 'Found a hat!' if $name =~ /hat/;

The match operator (m/ /, abbreviated / /) identifies a regular expression, in this example, it’s hat. This pattern is not a word. Instead, it means “the h character, followed by the a character, followed by t.” Each character in the pattern is an indivisible element (an ...