一、 metacharacter
1. line head and line end ------- ^, $
2. character class ------ [ ] (match exactly one character)
3. negated character class --------- [^……]
ep:
grep -e ' q[^u]' not match "iraq", because 'q[^u]' means q followed by a character that is not u
so, there must be a character followed q.
4. any character ---------- dot(.)
if within character class, the dot doesn't mean any character
5. alternatives ------------ |
if within character class. it doesn't mean it
6. word starting and word ending --------- \<, \>
7. optional item ------ ? (zero or one character)
8. repetition
+ --------------- one or as many times as possible
* --------------- none, one or as many times as possible
9. defined range of matches: intervals -------------- {n, m}
10. parenthese and backrefference
ep: egrep -i "([a-z])([0-9])\1\2 " files
\1------------ mean [a-z]
\2------------ mean [0-9]
summary:
Mastering Regular Expresstion notes(1)
最新推荐文章于 2020-01-27 18:35:33 发布