Thursday, February 21, 2008
Learning Perl, 4th Edition Notes 0x6
Learning Perl, 4th Edition Notes 0x6 by DaNmarner
* The support for regular expressions (patterns) in perl allows fast, flexible and reliable string handling.
* Some considered Regular Expression, whose function is to judge whether a string matches the template it stands for or not, a simple programming language.
* Pattern is match is generally being used to return a true or false value. It's almost always found in if or while structure.
* Some characters have special meanings in regular expression. These characters are named metacharacter. When matching them as a literal character, put backslash before them.
* Metacharacter dot (.) matches any single character except a new line. Backslash itself is a metacharacter, too.
* Use quantifiers when the quantitiy of the preceding item needs to be specified in a regular expression. A question mark (?) means the preceding item occurs 0 or 1 time. The plus (+) quantifier means 1 or more, while the star (*) means both.
* Parentheses are the metacharacters that group the stuff.
* The vertical bar (|) means "or".
* A list of possible characters inside square brackers ([]) is called a character class. Which matches any single characters from within the class.
* Hyphen (-) specifiys a range of characters in character classes.
* A caret (^) at the start of a character class negates it.
* Several character class shortcuts: d leaded by a backslash stands for [0-9], while w for [A-Za-z0-9_] and s for [\f\t\n\r ]. To negate them, use capital letters instead.
Labels:
Notes,
Perl,
Programming,
Regular Expression,
Script
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment