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.
Simple matches - Perl Tutorial
From the course: Perl 5 Essential Training
Simple matches
- [Voiceover] In its simplest form, a regular expression is used to match characters in a string. If I come in here and just put an i in my regular expression, this matches the single letter i, and if I run this, of course it's True because there is an i. There's actually several i's in my string. On the other hand, if I use a caret here at the beginning, this'll match an i only if it's at the beginning of the string. We can see that there is no i at the beginning of the string and so this evaluates to False. On the other hand, if I change this to a T, now when I run it, I get True because there is a T at the beginning of the string. Or I can make this at the end of the string with the $, and this'll anchor that irregular expression to the end of the string, the end of the line. Of course, if I run this it says False because there is no T at the end of the line. If I make this a t, now it will evaluate True. You can also do slightly more complex matches, For instance, if I wanted to…
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
-
-
-
-
-
-
-
-