Horje
perl contains substring Code Example
perl contains substring
# 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 $ @ % Code Example perl $ @ % Code Example
perl comparison operators Code Example perl comparison operators Code Example
perl exit loop Code Example perl exit loop Code Example
perl post condition Code Example perl post condition Code Example
perl input output Code Example perl input output Code Example

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