Regex: Difference between revisions

Content added Content deleted
Line 6: Line 6:
== Metacharacters ==
== Metacharacters ==


{| class="wikitable"
{|
|-
| Metacharacters Defined || Metacharacter Examples
! Metacharacters Defined !! Metacharacter Examples
|-
|-
| MChar || Definition || Pattern || Sample Matches
| MChar || Definition || Pattern || Sample Matches
Line 23: Line 24:
| [...] || Explicit set of characters to match. || a[bB]c || abc, aBc
| [...] || Explicit set of characters to match. || a[bB]c || abc, aBc
|-
|-
| (...) || Logical grouping of part of an expression. (abc){2} abcabc
| (...) || Logical grouping of part of an expression. || (abc){2} || abcabc
|-
|-
| * || 0 or more of previous expression. ab*c ac, abc, abbc, abbbc, ...
| * || 0 or more of previous expression. || ab*c || ac, abc, abbc, abbbc, ...
|-
|-
| + || 1 or more of previous expression. ab+c 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
| ? || 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
| \ || 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
|}
|}


== Character Escapes ==
== Character Escapes ==