Hello,

I am wondering on some metacharacters in regular expressions. According to Wall et al. (2000, p. 158), there are 12 metacharacters: * + ? . \ | ( ) [ { ^ $ On the other hand, the Perl regular expressions quick start (http://perldoc.perl.org/perlrequick.html ) cites 14 metacharacters: {}[]()^$.|*+?\

First, I am not quite sure about the status of } and ]. Can somebody explain the discrepancy between the two sources?

In addition, { and } seem to be fully acceptable characters outside an expression like {MIN, MAX} and patterns m/{my string}/ or m/{my string/ do not raise any exception or error. This is not the case for ( and the instruction m/(my string/ stops the program with an "unmatched" message. My question is: What are the different escape treatments for the different metacharacters?

A simple solution for a programmer that would like to ignore this would be to quote every purported metacharacter, when it appears as a literal; but I would like to understand how the algorithm really works... Do you know where I could find a clarification on that?

Thank you in advance.

Pierre

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to