Matching with a Regular Expression, REGEX, in Perl
You have a variable named $jiji that contains a sentence.
$jiji="I see London.";
You test the variable $jiji for the word london
if ($jiji =~ m/london/i) {
print "Matches!";
}
else {
print "Doesn't Match!";
}
NOTES:
-The i at the end of /london/i makes the match pattern case-insensitive. Remove the i to make match case-sensitive.
Copy and Paste Perl Code:
#!/usr/bin/perl
print "Content-type:text/html\n\n";
$jiji="I see London.";
if ($jiji =~ m/london/i) {
print "Matches!";
}
else {
print "Doesn't Match!";
}
exit;
Resources:
Getting What is Matched in Perl
Click HERE to comment or discuss at iLoveTheCode GOOGLE Group
| | | |
| | | |
| | HTML Gary B. Shelly, Th... | |