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.

Matching metacharacters

Matching metacharacters - Perl Tutorial

From the course: Perl 5 Essential Training

Start my 1-month free trial

Matching metacharacters

- [Voiceover] Perl uses a number of metacharacters with its regular expressions. You need to take special care in order to match those characters in a regular expression, and if I go ahead in here, and I put some parentheses in my string, now when I go ahead and run it, you can see that we have the match there, but what if I wanted to match the parentheses and everything within them? So, in order to match the actual parentheses, I need to escape the parentheses, like this, and so what I've done is, the parentheses that I wanna match, I've added a backslash character before. That's the opening one and that's the closing one, and then my regular parentheses, that are actually being interpreted and used, do not have the backslash, so if I want the regular expression engine to use the parenthesis for the meaning of the parenthesis within the regular expression, then I don't have to use a backslash If I want the regular expression engine to actually match the literal character of the…

Contents