Horje
perl match pattern Code Example
perl match pattern
# 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




14

Related
perl match regex Code Example perl match regex Code Example
perl compare scalars Code Example perl compare scalars Code Example
perl hash operations Code Example perl hash operations Code Example
perl while loop Code Example perl while loop Code Example
perl associative array Code Example perl associative array Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
12