擴充Regex
1. 擴充Regex擴充Regex ERE Extended Regular Expressions 比基本RegexBRE 擁有更強大的功能。2. ERE字元egrep表示使用擴充Regex,
可以用 grep -E 代替
+ 重複前面字元一次或多次 要匹配 god , good, goood 使用: grep -E 'go+d' test? 重複前面字元0次或一次 匹配gd 或 god, 使用 grep -E 'go?d' test| 表示 或 匹配good或bad,使用 grep -E 'good|bad' test() 分組 要尋找glad 或good, g和d相同,把la 和oo分組: grep -E 'g(la|oo)d' test()+ 多個重複的群組的判斷 匹配 AabcabcabcC 中間abc為多組 grep -E 'A(abc)+C' test
3. 簡寫
簡寫的特殊字元
Character Class Abbreviations\dMatch any character in the range 0 - 9 (equivalent of POSIX [:digit:])\DMatch any character NOT in the range 0 - 9 (equivalent of POSIX [^[:digit:]])\sMatch any whitespace characters (space, tab etc.). (equivalent of POSIX [:space:] EXCEPT VT is not recognized)\SMatch any character NOT whitespace (space, tab). (equivalent of POSIX [^[:space:]])\wMatch any character in the range 0 - 9, A - Z and a - z (equivalent of POSIX [:alnum:])\WMatch any character NOT the range 0 - 9, A - Z and a - z (equivalent of POSIX [^[:alnum:]])Positional Abbreviations\bWord boundary. Match any character(s) at the beginning (\bxx) and/or end (xx\b) of a word, thus \bton\b will find ton but not tons, but \bton will find tons.\BNot word boundary. Match any character(s) NOT at the beginning(\Bxx) and/or end (xx\B) of a word, thus \Bton\B will find wantons but not tons, but ton\B will find both wantons and tons.
地址:http://blog.csdn.net/yonggang7/article/details/39119457