1. Why does POE pass parameters as array slices? http://poe.perl.org/?POE_FAQ/calling_convention 2. perl regular expression fast referecnces metacharacters are {}[]() ^ $ . | * + ? a metacharacter can be matched by putting a backslash befo
1. Why does POE pass parameters as array slices?
http://poe.perl.org/?POE_FAQ/calling_convention
2. perl regular expression fast referecnces
metacharacters are
{ } [ ] ( ) ^ $ . | * + ?
a metacharacter can be matched by putting a backslash before it
anchor metacharacters ^ and $ .
The anchor ^ means match at the beginning of the string and the anchor $ means match at the end of the string, or before a newline at the end of the string.
"housekeeper" =~ /keeper/; # matches
"housekeeper" =~ /^keeper/; # doesn't match
"housekeeper" =~ /keeper$/; # matches
"housekeeper " =~ /keeper$/; # matches
/cat/; #matches 'cat'
/[bcr]at/; #matches 'bat', 'cat', or 'rat'
/item[0123456789]/; #matches 'item0' or ... or 'item9'
"abc" =~ /[cab]/; #matches 'a'
/[yY][eE][sS]/ can be rewritten as /yes/i.
/[/]c]def/; # matches ']def' or 'cdef'
$x = 'bcr';
/[$x]at/; # matches 'bat', 'cat', or 'rat'
/[/$x]at/; # matches '$at' or 'xat'
/[//$x]at/; # matches '/at', 'bat, 'cat', or 'rat'
/item[0-9]/; # matches 'item0' or ... or 'item9'
/[0-9bx-z]aa/; # matches '0aa', ..., '9aa',
# 'baa', 'xaa', 'yaa', or 'zaa'
/[0-9a-fA-F]/; # matches a hexadecimal digit
/[0-9a-zA-Z_]/; # matches a "word" character,
# like those in a Perl variable name
/[^a]at/; # doesn't match 'aat' or 'at', but matches
# all other 'bat', 'cat, '0at', '%at', etc.
/[^0-9]/; # matches a non-numeric character
/[a^]at/; # matches 'aat' or '^at'; here '^' is ordinary
/d matches a digit, not just [0-9] but also digits from non-roman scripts
/s matches a whitespace character, the set [/ /t/r/n/f] and others
/w matches a word character (alphanumeric or _), not just [0-9a-zA-Z_] but also digits and
characters from non-roman scripts
/D is a negated /d; it represents any other character than a digit, or [^/d]
/S is a negated /s; it represents any non-whitespace character [^/s]
/W is a negated /w; it represents any non-word character [^/w]
The period '.' matches any character but "/n" (unless the modifier //s is in effect, as explained
below).
//d/d:/d/d:/d/d/; # matches a hh:mm:ss time format
/[/d/s]/; # matches any digit or whitespace character
//w/W/w/; # matches a word char, followed by a
# non-word char, followed by a word char
/..rt/; # matches any two chars, followed by 'rt'
/end/./; # matches 'end.'
/end[.]/; # same thing, matches 'end.'
"cats and dogs" =~ /cat|dog|bird/; # matches "cat"
"cats and dogs" =~ /dog|cat|bird/; # matches "cat"
/(a|b)b/; # matches 'ab' or 'bb'
/(ac|b)b/; # matches 'acb' or 'bb'
/(^a|b)c/; # matches 'ac' at start of string or 'bc' anywhere
/(a|[bc])d/; # matches 'ad', 'bd', or 'cd'
/house(cat|)/; # matches either 'housecat' or 'house'
/house(cat(s|)|)/; # matches either 'housecats' or 'housecat' or
# 'house'. Note groups can be nested.
/(19|20|)/d/d/; # match years 19xx, 20xx, or the Y2K problem, xx
"20" =~ /(19|20|)/d/d/; # matches the null alternative '()dd',
# because '20dd' can't match
声明:本网页内容旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。TEL:177 7030 7066 E-MAIL:11247931@qq.com