Search⌘ K
AI Features

Regex Operators

Explore Perl regex operators to efficiently match patterns, bind regexes to strings, and perform substitutions. Learn to create reusable regexes with qr// and combine them for complex text processing.

Match and binding operators

A regex can be as simple as a substring pattern:

Perl
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 ...