Basic Matching Rules

C Styled Script
Reference Manual

<< Back  End  Next >>
 
 
INDEX
Introduction
Installation
Using The CSS Executive
Language
Directives
System Library
String Library
Regular Expression Lib.
   Basic Matching Rules
   Additional Syntax Specs
   Order Of Precedence
   rexClose
   rexMatch
   rexOpen
   Sample
File Library
Database Library
C API
C++ API
CSS Links
  

An ordinary character matches itself. The simplest form of regular expression is a string of characters with no special meaning. A special character preceded by a backslash matches itself. For basic regular expressions (BREs), the special characters are:

      . [ \ * ^ $

For extended regular expressions (EREs), the special characters also include:

      ( ) + ? { |

(EREs are supported when you specify the rexOpenExtended flag inrexOpen.)

A period (.) without a backslash matches any single character. For EREs, it matches any character except the null character. An expression within square brackets ([ ]), called a bracket expression, matches one or more characters or collating elements.

Bracket Expressions

A bracket expression itself contains one or more expressions that represent characters, collating symbols, equivalence or character classes, or range expressions:

[string]
Matches any of the characters specified. For example, [abc] matches any of a, b, or c.

[^string]
Does not match any of the characters in string. The caret immediately following the left bracket ([) negates the characters that follow. For example, [^abc] matches any character or collating element except a, b, or c.

[collat_sym-collat_sym]
Matches any collating elements that fall between the two specified collating symbols, inclusive. The two symbols must be different, and the second symbol must collate equal to or higher than the first. For example [r-t] would match any of r, s, or t.

NOTE: To treat the hyphen (-) as itself, place it either first or last in the bracket expression, for example: [-rt] or [rt-]. Both of these expressions would match -, r, or t.
[[.collat_symbl.]]
Matches the collating element represented by the specified single or multicharacter collating symbol collat_symbl. For example [[.ch.]] matches the character sequence ch. (In contrast, [ch] matches c or h.)

[[=collat_symbl=]]
Matches all collating elements that have a weight equivalent to the specified single or multicharacter collating symbol collat_symbl. For example, assuming a, à, and â belong to the same equivalence class, [[=a=]] matches any of the three. If the collating symbol does not have any equivalents, it is treated as a collating symbol and matches its corresponding collating element (as for [..]).

[[:char_class:]]
Matches any characters that belong to the specified character class char_class. For example, [[:alnum:]] matches all alphanumeric characters.
NOTE: To use the right bracket (]) in a bracket expression, you must specify it immediately following the left bracket ([) or caret symbol (^). For example, []x] matches the characters ] and x; [^]x] does not match] or x; [x]] is not valid.

You can combine characters, special characters, and bracket expressions to form REs that match multiple characters and subexpressions. When you concatenate the characters and expressions, the resulting RE matches any string that matches each component within the RE. For example, cd matches characters 3 and 4 of the string abcde;ab[[:digit:]] matches ab3 but not abc. For EREs, you can optionally enclose the concatenation in parentheses.

 Copyright © IBK LandquartLast revised by Peter Koch, 24.02.00<< Back  Top  Next >>