1、[^xx] 表示取反
root@pc1:/home/test# lsa.txt
root@pc1:/home/test# cat a.txt ##測試資料
333d g 83
d g !_ d g
! ! !, . ?root@pc1:/home/test# grep -v "3"
a.txt ## 只要匹配到3就排除
d g !_ d g
! ! !, . ?root@pc1:/home/test# grep "
[^3]
"a.txt ## 只有全部為3才排除
d g 83
d g !_ d g
! ! !, . ?
root@pc1:/home/test# lsa.txt
root@pc1:/home/test# cat a.txt
333d g 83
d g !
555_ d g
! ! !, . ?root@pc1:/home/test# grep "
[^3]
"a.txt
d g 83
d g !
555_ d g
! ! !, . ?root@pc1:/home/test# grep "
[^35]
"a.txt ## 這裡3和5是或的關係
d g 83
d g !_ d g
! ! !, . ?
2、-w 表示匹配字元數字
root@pc1:/home/test# lsa.txt
root@pc1:/home/test# cat a.txt
333d g 83
d g !
555_ d g
! ! !, . ?root@pc1:/home/test# grep "\w"
a.txt ## 匹配字元數字及下劃線
333d g 83
d g !
555_ d g
-w表示匹配非字元數字:
root@pc1:/home/test# lsa.txt
root@pc1:/home/test# cat a.txt
333d g 83
d g !
555_ d g
!!!,.?root@pc1:/home/test# grep "\w"
a.txt ## 匹配非字元數字及下劃線
d g 83
d g !_ d g
!!!,.?
3、
linux中正規表示式簡介
1.正規表示式 正規表示式 regular expression,簡寫re 是通過一些特殊字元的排列組成。正規表示式並不是乙個工具程式,而是一種字串處理的標準依據。如果想要使用正規表示式來處理字串,就必須使用支援正規表示式的工具程式才行,這類工具有很多,比如sed,awk,grep等。值得注意的是,...
Java中正規表示式 誤區記錄
經常看見正規表示式 括號什麼什麼括號加,但是一直存在誤解,寫這個來做記錄 例如 scdn 官方解釋 乙個或者更多個 官方匹配模板集 我的誤區模板集 csdnbanabanacsdncsdncsdn 官方結果 csdn和csdncsdncsdn 我臆想中的結果 csdn和csdncsdn,csdncs...
JS中正規表示式
js中正規表示式有幾種不同的使用方法,一些用法是通過字串物件來使用,另外一些通過正規表示式物件使用。一 regexp 正規表示式 的屬性和方法 1 屬性 regexp的例項有幾個唯讀的屬性 global表示是否為全域性匹配,igorecase表示是否忽略大小寫,multiline表示是否為多行匹配,...