Beruflich Dokumente
Kultur Dokumente
(Regular Expression)
Prepared by: Genevieve C. Oca
Common
Operators for
Regular
Operators
Basic operators
. Arbitrary
\, escape
character
? Optional
[] character class
character
*, + repeated
expression
| alternative
^ beginning of line
$ end of line
/ trailing context
{} repetitions
Basic operators
. Arbitrary
\, escape
character
? Optional
[] character class
character
*, + repeated
expression
| alternative
^ beginning of line
$ end of line
/ trailing context
{} repetitions
\, escape
Converts operators to text.
Examples:
\? rule for a question mark
\* rule for an asterisk
* same as above
a\+\+ same as a++
Basic operators
. Arbitrary
\, escape
character
? Optional
[] character class
character
*, + repeated
expression
| alternative
^ beginning of line
$ end of line
/ trailing context
{} repetitions
. Arbitrary character
Stands for any character.
Examples:
. This will accept one character
.oca. This will accept one character
Basic operators
. Arbitrary
\, escape
character
? Optional
[] character class
character
*, + repeated
expression
| alternative
^ beginning of line
$ end of line
/ trailing context
{} repetitions
[ ] character class
A set of characters that can match
character class
[ ] character class
Examples:
[a-zA-Z] rule for a single letter
[0-9] rule for a single digit
[^a-zA-Z] anything except a letter
[\n\t] a carriage return or a tab
If the dash sign needs to be a part of a character
Basic operators
. Arbitrary
\, escape
character
? Optional
[] character class
character
*, + repeated
expression
| alternative
^ beginning of line
$ end of line
/ trailing context
{} repetitions
? Optional character
Zero or one occurrence of the
preceding expression.
[-+]? optional negative or positive
sign
Colou?r can match color or colour
Basic operators
. Arbitrary
\, escape
character
? Optional
[] character class
character
*, + repeated
expression
| alternative
^ beginning of line
$ end of line
/ trailing context
{} repetitions
*, + repeated expression
* : zero or more occurrences of
Basic operators
. Arbitrary
\, escape
character
? Optional
[] character class
character
*, + repeated
expression
| alternative
^ beginning of line
$ end of line
/ trailing context
{} repetitions
| altrnative
Any of the alternative expressions
will be recognized.
Example:
0|1|2|3|4|5|6|7|8|9 a digit, the
hard way
oca|chu|meow can match oca or
chu or meow
Basic operators
. Arbitrary
\, escape
character
? Optional
[] character class
character
*, + repeated
expression
| alternative
^ beginning of line
$ end of line
/ trailing context
{} repetitions
^ beginning of line
The expression following this
Basic operators
. Arbitrary
\, escape
character
? Optional
[] character class
character
*, + repeated
expression
| alternative
^ beginning of line
$ end of line
/ trailing context
{} repetitions
$ end of line
If the expression is ended by this
Basic operators
. Arbitrary
\, escape
character
? Optional
[] character class
character
*, + repeated
expression
| alternative
^ beginning of line
$ end of line
/ trailing context
{} repetitions
/ trailing context
The format is: Expr1/Expr2. This
Basic operators
. Arbitrary
\, escape
character
? Optional
[] character class
character
*, + repeated
expression
| alternative
^ beginning of line
$ end of line
/ trailing context
{} repetitions
{}
Allows different kinds of repetition.
Example:
a{1,5} the same as (a|aa|aaa|aaaa|
aaaa)
a{1,} the same as a+, one or more
repetitions of a
a{2,} two (2) or more repetitions of a
a{5} exactly five (5) repetitions of a
Basic operators
. Arbitrary
\, escape
character
? Optional
[] character class
character
*, + repeated
expression
| alternative
^ beginning of line
$ end of line
/ trailing context
{} repetitions
^^,
I can do all things through
Christ
Who strengthens me
-Philippians 4:13