Regex: Difference between revisions

933 bytes added ,  6 years ago
no edit summary
m (Protected "Regex" ([Edit=Allow only logged in users] (indefinite) [Move=Allow only logged in users] (indefinite) [Delete=Allow only logged in users] (indefinite)))
No edit summary
Line 1:
[[Category:Linux]]
 
=Syntax=
{{UC}}
 
Metacharacters Defined || Metacharacter Examples
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.
{...} Explicit quantifier notation.
[...] Explicit set of characters to match.
(...) Logical grouping of part of an expression.
* 0 or more of previous expression.
+ 1 or more of previous expression.
? 0 or 1 of previous expression; also forces minimal matching when an expression might match several strings within a search string.
\ Preceding one of the above, it makes it a literal instead of a special character. Preceding a special matching character, see below.
 
 
 
 
 
bill|ted ted, bill
ab{2}c abbc
a[bB]c abc, aBc
(abc){2} abcabc
ab*c ac, abc, abbc, abbbc, ...
ab+c abc, abbc, abbbc, ...
ab?c ac, abc
a\sc a c
 
 
 
{| class="wikitable"