Home > Articles > Web Services > XML

  • Print
  • + Share This
From the author of

Metacharacters

A metacharacter typically specifies an "instruction" such as grouping, alternatives, or cardinality. Furthermore, expressions that contain metacharacters may be concatenated. The Characters section of this document covers all characters besides metacharacters.

The following table illuminates all of the metacharacters, since they are invaluable in almost any regular expression:

Metacharacter

Description

Regular Expression

Sample Match

\

Precedes a metacharacter (to specify that character) or specifies a single- or multiple-character escape sequence.

\*\d*\*

"*1234*"

?

Zero or one occurrences.

ab?c

"ac"

"abc"

*

Zero or more occurrences.

ab*c

"ac"

"abc"

"abbbbbc"

+

One or more occurrences.

ab+c

"abc"

"abbbbbc"

|

The "or" operator.

ab|cd

"ab"

"cd"

(

Start grouping.

a(b|c)d

"abd"

"acd"

)

End grouping.

a(b|c)d

"abd"

"acd"

{

Start repetition.

a{2,4}

"aaa"

}

End repetition.

a{2,4}

"aaa"

[

Start range.

xx[A-Z]*xx

"xxABCDxx"

]

End range.

xx[A-Z]*xx

"xxABCDxx"


  • + Share This
  • 🔖 Save To Your Account