擴充Regex

來源:互聯網
上載者:User

擴充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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.