Perl Matching

[Solved] Perl Matching | Perl - Code Explorer | yomemimo.com
Question : perl matching

Answered by : charlesalexandre-roy

# Basic syntax:
$your_string =~ /regex pattern to match/
# Use !~ for not matching
# Example usage:
# Check if the regex pattern your is found in the variable $your_string
my $your_string = "this is your string";
if ($your_string =~ /your/) {	print "your_string contains your\n"
}
--> your_string contains your
# Check if the regex pattern y?o*u+r is found in the variable $your_string
my $your_string = "this is your string";
if ($your_string =~ /y?o*u+r/) {	print "your_string matches pattern\n"
}
--> your_string matches pattern
# Where, in regex:
#	- ? matches 0 or 1 of the preceeding characters
#	- * matches 0 or more of the preceeding characters
#	- + matches 1 or more of the preceeding characters

Source : https://learnxinyminutes.com/docs/perl/ | Last Update : Fri, 18 Mar 22

Answers related to perl matching

Code Explorer Popular Question For Perl