From the course: Perl 5 Essential Training
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Common modifiers - Perl Tutorial
From the course: Perl 5 Essential Training
Common modifiers
- [Voiceover] Modifiers are used to modify the default behavior of the regex parser. Here's a working copy of match.pl from chapter nine of the exercise files, and, you notice if I just run this, I get true, because this match is true. However if I change this to use capital letters and I run it again, you see now it says false, because that no longer matches. I can modify this regular expression to match ignoring case, so it will match upper case, lower case, mixed case, anything, and if I save this and run it, now it's true again, because it's matching without regard to case. So, we return this to its previous state and we're going to now look at the /g modifier, which is the global modifier. In order to understand this, I'm gonna use a regular expression on list context. So I'm gonna say foreach, and that makes it a list context. $s slash i, just the letter i, like that, and that'll list every instance of i in the match. and when I run this, you notice that it only gives us one. It…
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
-
-
-
-
-
-
-
-
-
-
-
About regular expressions4m 8s
-
Matching text2m 9s
-
Common modifiers4m 58s
-
Extracting matches2m 5s
-
Getting a list of matches1m 46s
-
Simple matches2m 46s
-
Matching wildcards4m 38s
-
Matching classes of characters4m 23s
-
Matching metacharacters1m 37s
-
Search and replace4m 32s
-
Splitting strings2m 18s
-
-
-
-
-
-
-
-