Regular Expressions

Top  Previous  Next

A good tutorial on regular expressions can be found here: http://www.regular-expressions.info/tutorial.html. Girder uses PCRE for regular expression in Events and gir.addEventHandler. Lua uses it's own regular expression, which can be found here: http://promixis.com/lua/manual.html#5.4.1

 

Cheat Sheet

This sheet applies to the PCRE regular expression used in Girder. PCRE is used in gir.addEventHandler and Event Matching. Note that when typing regular expression in Lua the backslash (\) must be escaped, thus "\\".

Anchors

Sequence

Description

^

Start of line

\A

Start of a string

$

End of a line

\Z

End of a string

\b

Word boundary

\B

Not a word boundary

\<

Start of a word

\>

End of a word

Assertions

Sequence

Description

?=

Look ahead

?!

Negative Look Ahead

?<=

Look behind

?!=

Negative look behind

?<!

Negative look behind

?>

Once only sub-expression

?()

An "If Then" condition

?()|

An "If then else" condition

?#

An comment

Quantifiers

Sequence

Description

*

0 or more

*?

Un-greedy 0 or more

+

1 or more

+?

Un-greedy 1 or more

?

0 or 1

??

Un-greedy 0 or 1

{2}

Exactly 2

{2,}

2 or more

{2,6}

2,3,4,5 or 6

{2,6}?

Ungreedy 2,3,4,5 or 6

 

Character Classes

Sequence

Description

\c

Control Character

\s

White space

\S

Not White space

\d

Digit (0-9)

\D

Not a digit

\w

A word

\W

Not a word

\x

Hexadecimal (lower case!)

\O

Octal

Special Characters

Sequence

Description

\

Escape Character

\n

Newline

\r

Carriage Return

\t

Tab

\v

Vertical Feed

\f

Form Feed

\a

Alarm

[\b]

Backspace

\e

Escape

Ranges

Sequence

Description

(a|b)

a or b

.

Any character except a newline

( )

Capture group

(?: )

Passive group

[abc]

a, b or c

[^abc]

Not a, b or c

[a-z]

Letters between a and z

[A-Z]

Letters between A and Z

[0-9]

Numbers between 0-9

[A-Fa-f0-9]

Case insensitive hexadecimal