perlnote6

#!/usr/bin/perl -w use strict; =head   this section describes regular expression =cut =head1 1 operators   match: =~   not match: !~ 2 types for use   match: m/pattern/ or /pattern/   replace: s/pattern/replacement/   transform: tr/pattern/replacement/ 3 patterns   . match all chars except "/n";   x? count of x = 0 or 1;   x* count of x >= 0;   x+ count of x >=1;   .* match any char whose count >= 0;   .+ match any char whose count >= 1;   x{m} match x whose count = m;   x{m,n} match x whose count is in [m, n];   x{m,} match x whose count >= m;   x{,n} match x whose count <= n;   [] match any char present in [];   [^] match any char NOT in [], ^ ONLY affect when at the beginning of pattern;   [0-9] match one digital char;   [^0-9] match one char except digital char;   /d equal to [0-9];   /d+ equal to [0-9]+;   /D match one non-digital char;   /D+ match one or more than one non-digital char;   /w match one char in [a-zA-Z_0-9];   /w+ equal to [a-zA-Z_0-9]+;   /W equal to [^a-zA-Z_0-9];   /W+ equal to [^a-zA-Z_0-9]+;   /s match char in [/n/t/r/f], space char;   /s+ [/n/t/r/f]+;   /S [^/n/t/r/f];   /S+ [^/n/t/r/f]+;   /b ;   /B ;   /^pattern/ match very beginning chars;   /pattern$/ match very end chars; 4     /pattern/i: ignore if the pattern is in upper or lower;   /pattern/s: match pattern during multi-lines, ignore "/n";   s/pattern/replacement/g: replace all strings matching pattern;   s/pattern/replacement/e: treat replacement as a expression, not a string; 5 match results   m/(p1)(p2)../:   use (pattern), strings which are matched the patterns in () can be represented   in the way: $1, $2,..., which $1 represent the first string matched the p1;   m/((p1)(p2))/: $1 is the string matched the most left ();   $1 is always stored in memory unless the next match is successful; so if the   current match failed, $1 stored the value matched by last time; 6 exchange for strings   =cut
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值