ibm Rational Rhapsody 7.5 — Parsing regular expressions

Regular expressions This regular expression, enclosed in parentheses, matches a sequence of two ranges, any single uppercase or lowercase letter, or underscore character; followed by zero or more uppercase or lowercase letters, digits 0-9, or the underscore character. Parsing regular expressions Parts of the expression contained within parentheses are called tokens . The regular expression for the ParseErrorMessage property is as follows: ([^(]+)[(]([0-9]+)[)] [:] (error|warning|fatal error) It consists of the following parts: Љ ([^(]+) This is the first token. The caret at the beginning of the set is a NOT operator that matches any character except those in the set.

This token tells the parser to ignore all characters until the first occurrence of an open parenthesis. Љ [(] The parser should search for exactly one opening parenthesis. Љ ([0-9]+) This is the second token It tells the parser to search for a sequence of one or more digits in the range of 0 to 9. Љ [)] The parser should search for exactly one closing parenthesis. Љ [:] The parser should search for exactly one colon. Љ (error|warning|fatal error} This is the third token.

It tells the parser to search for one of the strings “error,” “warning,” or “fatal error.” The ErrorMessageTokensFormat property works with ParseErrorMessage to determine how many tokens can be contained in an error message, and the relative positions in the message string of tokens that represent the file name and line number of the error, respectively. The second token in the sample regular expression would most likely represent a line number, depending on how ErrorMessageTokensFormat was defined. Based on this regular expression, the parser would interpret the string “ (3457):warning ” as a valid error message indicating a warning condition at line 3457 in the program.

Rational Rhapsody 161