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 classes of characters - Perl Tutorial
From the course: Perl 5 Essential Training
Matching classes of characters
- [Voiceover] Regular expressions include the ability to match a class of characters like any alphabetic character or any of the digits four, seven, or nine. For example, if I wanna match a whitespace character, I can use this. So the backslash followed by the lowercase s will match anything that is whitespace. This includes spaces, tabs, new lines, form feeds, and vertical tabs. The capital S matches anything that is not whitespace, and there's a pattern here. In a lot of these classes, the capital version is negated. So it's anything that is not. So this is useful for finding words. For example here, I'm just gonna change this around a little bit to say "my @a", so I'm making an array called "a", equals, and I'm putting a slash g here so that it gives us all the matches from a line and take that out and instead, say "foreach @a". So when I run this, getting anything that is not whitespace. So it's basically giving me a list of all of the individual letters in the string. And if I…
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)
-
-
-
-
-
-
-