From the course: Perl 5 Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Matching text - Perl Tutorial
From the course: Perl 5 Essential Training
Matching text
- [Voiceover] The fundamental purpose of regular expressions is to match text. The match operator returns a logical value. And so, down here in line nine, you notice that the match operator is used in a logical test for the if statement. So that's the match operator right there, the equals sign and the tilde symbol. And so if this match succeeds, and there is a match, it'll say True. And if there is no match, it'll say False. So we see that in the regular expression there we have this string l i n e, line. And you'll see that it's also in the string that we're testing against, $s, which is listed here as the string in the match operator. And so if I run this, we should get True as our result, and we do. So this is a simple way to test a regular expression. Another common way to test a regular expression is by using a precompiled regular expression and using a ternary operator. So that would look something like this. My $re, so that's for the precompiled regular expression which we…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
-
-
(Locked)
About regular expressions4m 8s
-
(Locked)
Matching text2m 9s
-
(Locked)
Common modifiers4m 58s
-
(Locked)
Extracting matches2m 5s
-
(Locked)
Getting a list of matches1m 46s
-
(Locked)
Simple matches2m 46s
-
(Locked)
Matching wildcards4m 38s
-
(Locked)
Matching classes of characters4m 23s
-
(Locked)
Matching metacharacters1m 37s
-
(Locked)
Search and replace4m 32s
-
(Locked)
Splitting strings2m 18s
-
(Locked)
-
-
-
-
-
-
-