grep 的常用元字元
Metacharacter | Function | Example | What It Matches |
---|---|---|---|
^ | Beginning-of-line anchor | '^love' | Matches all lines beginning with love. |
$ | End-of-line anchor | 'love$' | Matches all lines ending with love. |
. | Matches one character | 'l..e' | Matches lines containing an l, followed by two characters, followed by an e. |
* | Matches zero or more characters preceding the asterisk | ' *love' | Matches lines with zero or more spaces, followed by the pattern love. |
[ ] | Matches one character in the set | '[Ll]ove' | Matches lines containing love or Love. |
[^] | Matches one character not in the set | '[^A–K]ove' | Matches lines not containing a character in the range A through K, followed by ove. |
< | Beginning-of-word anchor | ' | Matches lines containing a word that begins with love. |
> | End-of-word anchor | 'love>' | Matches lines containing a word that ends with love. |
(..) | Tags matched characters | '(love)ing' | Tags marked portion in a register to be remembered later as number 1. To reference later, use 1 to repeat the pattern. May use up to nine tags, starting with the first tag at the leftmost part of the pattern. For example, the pattern love is saved in register 1 to be referenced later as 1. |
x{m} x{m,} x{m,n}[a] | Repetition of character x: m times, at least m times, or between m and n times | 'o{5}' 'o{5,}' 'o{5,10}' | Matches if line has 5 occurences of o, at least 5 occurences of o, or between 5 and 10 occurrences of |
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8730/viewspace-1034283/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 正規表示式中常用的元字元字元
- Linux 中grep命令如何匹配中文字元Linux字元
- Linux常用命令記錄-grepLinux
- 正則-元字元字元
- Markdown常用轉義字元字元
- 正規表示式元字元與普通字元字元
- 正規表示式 ^元字元字元
- 正規表示式 $ 元字元字元
- 『學了就忘』Linux基礎命令 — 31、grep命令和萬用字元Linux字元
- 正規表示式 \d元字元字元
- 正規表示式 \t 元字元字元
- 正規表示式 \t元字元字元
- 正規表示式 \0元字元字元
- 正規表示式 \s 元字元字元
- 正規表示式 \xxx 元字元字元
- 正規表示式 \r 元字元字元
- 正規表示式 \n 元字元字元
- 正規表示式 \W元字元字元
- 正規表示式 \w 元字元字元
- 正規表示式 點(.)元字元字元
- 正規表示式 \xnn元字元字元
- 正規表示式 \b元字元字元
- 正規表示式 \D 元字元字元
- 正規表示式 \uxxxx 元字元UX字元
- 正規表示式 \v 元字元字元
- 正規表示式 \f 元字元字元
- 正規表示式 \B 元字元字元
- Python字串刪除第一個字元常用的方法!Python字串字元
- grep的或操作
- word首行縮排2字元怎麼設定 word首行縮排2字元的方法字元
- 正規表示式元字元大整理字元
- Python中查詢字串某個字元最常用的方法!Python字串字元
- Python字元編碼的常用種類!Python基礎教程Python字元
- Linux grep命令的使用Linux
- grep 的使用場景
- vim 的 grep 外掛`Leaderf rg`:grep 和模糊匹配的完美結合
- grep 、awk
- 常用的正規表示式大全(數字、字元、固定格式)字元
- JS正規表示式從入門到入土(2)—— 元字元和字元類JS字元