Page tree

A regular expression is a pattern that describes a set of strings. A regular expression is a sequence of any of the following items:

  • literal character
  • matching character
  • repetition clause
  • alternation clause
  • subpattern grouped with parenthesis

Regular expressions syntax

The following table lists the regular expression syntax with its corresponding descriptions:

Syntax

Description

.

Matches any character; used as a wildcard when creating a search string.

*

Matches zero or more instances of the previous pattern item.

+

Matches one or more instances of the previous pattern item.

?

Matches zero or one instance of the previous pattern item.

( )

Groups subpattern; repetition and alternation operators apply to the entire preceding subpattern.

|

Allows for an alternation of a pattern.

For example, to match Hello or hello in a string, the regular expression should read: Hello|hello.

[ ]

Delimits a set of characters; the range is specified as [x-y].

If the first character in the set is ^, there is a match only when the remaining characters in the set are not present.

^

Anchors the pattern to the beginning of the string; this character must be the first character in the set.

$

Anchors the pattern to the end of the string; this character must be the last character in the set.

  • No labels

2 Comments

  1. It would be useful to include some examples on this page, in particular for the *** syntax, which is different than the more common .* syntax.

    For example, typical regular expression syntax when you are looking for a sentence that starts with "Something" followed by any number of characters would be:

    ^Something.*

    This document suggests the syntax should be:

    ^Something.***

    1. Hi Daniel,

      Thanks for pointing this out. We have corrected the documentation.

      Thanks,
      Shweta