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 wildcards

Matching wildcards - Perl Tutorial

From the course: Perl 5 Essential Training

Start my 1-month free trial

Matching wildcards

- Regular expressions have a simple, yet powerful, system of wildcards. Here's a working copy of wildcards.pl from chapter nine of the Exercise Files. And this is very much like our previous examples, except it's displaying the match with the $1 and the parentheses in the regular expression, so when I run this, it says Match is: text. So, this is just matching a literal string. If I put a period in here instead of the e, that's a wildcard. And so, that will match t and any character, and then x and t. So, I run this, it still says Match is: text. But if I come up here and change this e to a z and I run that, now it says Match text is: tZxt. On the other hand, if I put this back and I move that dot to after the word text, you notice that it comes up and it says false, because you cannot match past the end of the string. I could also match one or more of a particular character. So, if I run this, it'll get the matches t. And, on the other hand, if I put in a bunch of t's here and I run…

Contents