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

Simple matches - Perl Tutorial

From the course: Perl 5 Essential Training

Start my 1-month free trial

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…

Contents