|
IBM Rational Functional Tester Version 6.1 IBM Rational Functional Tester API Reference Project Version 2.0 |
||||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Class Summary | |
Regex | This is an efficient, lightweight regular expression evaluator/matcher class. |
Exception Summary | |
RegexSyntaxException | Thrown when constructing a RegularExpression with invalid syntax. |
The package com.rational.test.util.regex provides the regular expression classes.
This product includes software developed by the Apache Software Foundation (http://www.apache.org/). The regular expression implementation is based on org.apache.regexp and is similar to perl5.
A regular expressions is a way to describe a set of strings without having to list all the strings in the set.
There are many rules and special characters. Entire books have been written on regular expressions and how to use them.
Here are some simple examples. See the Regex documentation
for more details.
Regex("def").matches("abcdefg")
Certain characters are treated specially by Regex. The period (.) matches any single character.
Regex("a.c").matches("axcd")
The asterisk or star (*) matches any repeating sequence (0 or more) of the previous pattern.
Regex("a*d").matches("aaaaad")
Note that asterisk or star (*) matches 0 occurrences of the previous pattern.
Regex("a*d").matches("d")
The plus (+) matches any repeating sequence (1 or more) of the previous pattern.
Regex("a+d").matches("aaaaad")
False: Regex("a+d").matches("d")
The question mark (?) matches 0 or 1 of the previous pattern.
Regex("ab?c").matches("ac")
Regex("ab?c").matches("abc")
Parentheses can be used to group patterns.
Regex("a(bc)+d").matches("abcbcbcbcd")
You can indicate multiple choices using the vertical bar (|).
Regex("red|green|blue").matches("red")
Regex("x(red|green|blue)*x").matches("xredblueredx")
You can indicate a set of characters using square brackets ([]).
Regex("x[ab]x").matches("xax")
Regex("x[ab]x").matches("xbx")
Regex("[0-9]*").matches("12378")
|
|||||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |