beautypg.com

Bracket expressions – Visara Master Console Center Scripting Guide User Manual

Page 57

background image

Chapter 4 Regular Expressions

Scripting Guide

57

An RE ordinary character or an RE special character preceded by a
backslash or a period matches a single character.
A bracket expression matches a single character or a single collating
element.
An RE matching a single character enclosed in parentheses (a group)
matches the same strings as the RE without parentheses.

Bracket Expressions

A bracket expression is a non-null string enclosed in brackets “[ ]” that
matches any single character (or collating element) in the enclosed string.
For example, the RE “[a3][c5]” means “look for the character ‘a’ OR the
character ‘3’ immediately followed by the character ‘c’ OR the character
‘5’. When processed on each of the following strings:
String 1: “ab”
String 2: “acbcbc”
String 3: “123456”
String 4: “1b2q3c4i”
String 5: “13579”
The results are:
String 1: no match
String 2: match
String 3: no match
String 4: match
String 5: match
The two contiguous bracket expressions in the pattern match the
substrings ‘ac’, ‘3c’, and ‘35’ in those strings that “match”.
A bracket expression is a matching list expression (searching for
matching expressions) or a non-matching list expression (searching for
everything except the expressions). The bracket expression consists of
one or more

ƒ

Collating elements

ƒ

Collating symbols

ƒ

Equivalence classes

ƒ

Character classes

ƒ

Range expressions

Use bracket expressions to search for a matching expression or to search
for everything except the expression.
A right bracket occurring first in the expression (after an initial
circumflex “^”, if any) loses its special meaning, and represents itself in
the bracket expression. Otherwise, the right bracket terminates the
bracket expression, unless it appears in a collating symbol (such as [.].] )
or is the ending right bracket for a collating symbol, equivalence class, or
character class.