1. 正则表达式
email: =~ /^([0-9a-zA-Z]{3,}|[0-9a-zA-Z]+(-|_)?[0-9a-zA-Z_-]+\.?[0-9a-zA-Z]+)\@[0-9a-zA-Z]+\.[0-9a-zA-Z]+(\.\w+)?/;
ip =~/([0-9]{1,3}\.?){4}/;
. Match any character except a wrap character.
\w Match "word" character and [_0-9a-zA-Z]
\W Match non-word character [^_0-9a-zA-Z]
\s Match whitespace character [ \r\t\n\f]
\S Match non-whitespace character [^ \r\t\n\f]
\d Match digit character [0-9]
\D Match non-digit character [^0-9]
\t Match tab
\n Match newline
^ Match the head
$ Match the end
* Match 0 or more times
+ Match 1 or more times
? Match 0 or 1 times
{n} Match exactly n times
{n,} Match at least n times
{n,m} Match at least n but not more than m times
a|b match a or match b
2.自定义包/模块
包和模块的区别:
1.一个包的定义可以跨多个模块,一个模块中也可以有多个包定义;
2.定义模块时模块名必须和文件名一致,包无此要求;
注意:包和模块文件末尾需要加1;(return 1)