- 论坛徽章:
- 145
|
回复 1# lorihuang
/b[ae]?t/
1. [ae] => a or e
2. [ ]? => [] or "" (empty)
3. b[ae]?t => b[ae]t or bt => bat or bet or bt
/b[ae]+t/
1. []+
+ => 1 or more
[]+ => [] or [][] or [][][] or [][][]...[]
2. b[ae]+t
+ = 1, []+ = [] , b[ae]t => bat or bet
+ = 2, []+ = [][], b[ae][ae]t => baat or baet or beat or beet
+ = 3, []+ = [][][], b[ae][ae][ae]t => baaat or baaet or .... beet
+ = N, []+ = [][][]...[], baaa....at or ... or beee...et
/b[ae]{1,2}t/
1. []{1,2} => [] or [][]
2. b[ae]{1,2}t
[]{1} = [] , b[ae]t => bat or bet
[]{2} = [][], b[ae][ae]t => baat or baet or beat or beet
最后一个问题,书中说echo "saturday"|gawk '/sat(urday)?/{print $0}'匹配上,我自己尝试分别使用echo “saturday1”、"sat1urday"、"sat1u2rday"都能匹配上
/sat(urday)?/
1. ()? => () or "" (empty)
2. sat(urday)?
()? = () , sat(urday)? => saturday
()? = ""(empty), sat(urday)? => sat
后来我修改语句为echo "saturday"|gawk '/sat(urda)?y/{print $0}'时,发现saturday1234也能匹配上,但是当echo “saturda2y”、"sat1urday"、"sat1u2rday"都是无法匹配的,请问为什么?我是哪个地方没有理解透彻?
/sat(urda)?y/
1. ()? = ()
sat(urda)?y = saturday
2. ()? = "" (empty)
sat(urda)?y = saty
|
|