beautypg.com

Table 9. bracket expression rules – Visara Master Console Center Scripting Guide User Manual

Page 60

background image

Chapter 4 Regular Expressions

Scripting Guide

60

Bracket
Expression
Rule

Description

Equivalence

Class Expression

Specifies a set of collating elements that all sort to the

same primary location. An equivalence class is
enclosed in bracket-equal “[= =]” delimiters. An

equivalence class generally is designed to deal with
primary-secondary sorting, that is, for languages like

French that define groups of characters as sorting to

the same primary location and then having a tie-
breaking secondary sort.
For example, if x, y, and z are collating elements that

belong to the same equivalence class, the bracket
expressions “[[=x=]a]”, “[[=y=]a]”, and “[[=z=]a]” are

equivalent to [xyza]. Here we use x, y, and z as variables

representing characters in the same equivalence class. In
a typical example, x might be the collating element e

while y and z are the characters è and é respectively. If
the collating element within [= =] delimiters does not

belong to an equivalence class, the equivalence class

expression is treated as a collating symbol; that is, the
delimiters are ignored.

Range
Expression

A set of collating elements that falls between two
elements in the current collation sequence, inclusively.

It is expressed as starting and ending points separated
by a hyphen “-”. For example, the RE “1[a-d]2”, which

includes the bracket expression “[a-d]” containing the

range expression a through d, represents a pattern that
will match any of these strings: 1a2, 1b2, 1c2, and 1d2.

Range expressions depend on collating sequences.
A construction such as [a-d-g] is invalid.
A hyphen or right bracket may be represented as

collating symbols, ‘[.-.]’ or ‘[.].]’, anywhere in a bracket

expression. Otherwise, if both ‘-‘ and ‘]’ are required in
a bracket expression, the bracket must be first (after an

optional initial ^) and the hyphen last.
The hyphen character loses its special meaning in a
bracket expression if it occurs first (after an initial ‘^’, if

any), last, or as an ending range point in a range
expression. Examples:
[-df] and [df-] are equivalent and match any of the

characters d, f, or -
[^-df] and [^df-] are equivalent and match any

characters except d, f and -
[&-] matches any character between & and - inclusive
[-;] matches any characters between - and ; inclusive
[A--] is invalid, because A follows - in the collation
sequence

Table 9. Bracket Expression Rules.