- Tools

Egrep Metacharacter Summary

n3015m 2012. 11. 16. 09:42
정규식과 관련된 기본적인 메타케릭터 설명이다. Egrep을 기준으로 작성된거지만 대부분의 표준 정규식에서 지원된다.

Items to Match a Single Character

Metachracter Matches
. dot Matches any one character
[…] character class Matches any one character listed
[^…] negated character class Matches any one character not listed
\char escape character When char is a metacharacter,or the escaped combination is not otherwise special, matches the literal character

Items Appended to Provide "Counting" :The Quantifers

Metachracter Matches
? question One allowed, but it is optional
* start Any number allowed, but all are optional
+ plus At least one required; additional are optional
{min,max} specified range Min required, max allowed

Items That Match a Position

Metachracter Matches
^ caret Matches the position at the start of the line
$ dollar Matches the position at the end of the line
\< word boundary* Matches the position at the start of a word
\> word boundary* Matches the position at the end of a word

Other
Metachracter Matches
| alternation Matches either expression it separates
(…) parentheses Limits scope of alternation, provides grouping for the quantifiers, and "captures" for backreferences
\1,\2.. backreference* Matches text previously matched within first, second, etc., set of parentheses.

※ 참고자료
O'Reilly - Mastering Regular Expressions 2nd Edition