Metacharacters Defined |
|---|
| MChar | Definition | Pattern | Sample Matches |
|---|
| ^ | Start of a string. | ^abc | abc, abcdefg, abc123, ... | | $ | End of a string. | abc$ | abc, endsinabc, 123abc, .. | | . | Any character (except \n newline) | a.c | abc, aac, acc, adc, aec, ... | | | | Alternation. | bill|ted | ted, bill | | {...} | Explicit quantifier notation. | ab{2}c | abbc | | [...] | Explicit set of characters to match. | a[bB]c | abc, aBc | | (...) | Logical grouping of part of an expression. | (abc){2} | abcabc | | * | 0 or more of previous expression. | ab*c | ac, abc, abbc, abbbc, ... | | + | 1 or more of previous expression. | ab+c | abc, abbc, abbbc, ... | | ? | 0 or 1 of previous expression; also forces minimal matching when an expression might match several strings within a search string. | ab?c | ac, abc | | \ | Preceding one of the above, it makes it a literal instead of a special character. Preceding a special matching character, see below. | a\sc | a c |
|
|
thank Sara!
Trả lờiXóa