Regex: Difference between revisions
→Syntax
(→Syntax) |
(→Syntax) |
||
Line 4:
{{UC}}
== Metacharacters
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, ...▼
{...} 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.▼
{|
| Metacharacters Defined || Metacharacter Examples
|-
▲| MChar || Definition || Pattern || Sample Matches
|-
|-
|-
|-
| | || Alternation. || bill|ted || ted, bill
|-
|-
|-
|-
|-
|-
▲| ?
|-
▲| \
|}
== Character Escapes ==▼
▲Character Escapes
▲Escaped Char Description
▲ordinary characters Characters other than . $ ^ { [ ( | ) ] } * + ? \ match themselves.
\a Matches a bell (alarm) \u0007.
\b Matches a backspace \u0008 if in a []; otherwise matches a word boundary (between \w and \W characters).
Line 52:
== Character Classes ==
Char Class
. Matches any character except \n. If modified by the Singleline option, a period character matches any character. For more information, see Regular Expression Options.
[aeiou] Matches any single character included in the specified set of characters.
|