Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

A pattern (or a mask) is used for matching a given string of characters for "find" or "find and replace" operations, where some parts of the string are masked by wildcards. During run-time, these wildcard characters are evaluated to match the characters in the actual string.

...

Symbol

Description

Example

Matching Entries

?

The question mark indicates zero or one occurrences occurrence of the preceding element.

colou?r

color and colour

*

The asterisk indicates zero or more occurrences of the preceding element.

ab*c

ac, abc, abbc, abbbc, and so on

+

The plus sign indicates one or more occurrences of the preceding element.

ab+c

abc, abbc, abbbc, and so on, but not ac

{n}

The preceding item is matched exactly n times.

a{3}

aaa

{min,}

The preceding item is matched min or more times.

a{2,}

aa, aaa, aaaa, and so on

{min,max}

The preceding item is matched at least min times, but not more than max times.

a{1,3}

a, aa, aaa

.

The period matches any single character.

h.t

hot, hat, and hit

\d

Represents a numeric character.

Owner\d?

Owner1, Owner2, up to Owner9

\D

Represents a non-numeric character.

Owner1\D{1,6}

Owner1Nr, Owner1., Owner1.Phone, Owner1FName, and so on

|

Represents an OR selector between several strings.

Home|Office|Voicemail

Home, Office, and Voicemail

()

Parentheses are used to define the scope and precedence of the operators.

(Home|Office|Voicemail)Phone

\D*(Phone)\d+

HomePhone, OfficePhone, and VoicemailPhone 

Phone99, OfficePhone1, OfficePhone2, HomePhone1 and HomePhone12


[…]

Represents any single character within the brackets

h[oa]t

hot and hat, but not hit

[^…]

Matches every character except the ones inside brackets.

h[^oa]t

hit, but not hot and hat

...