Extended regular expressions – HP Integrity NonStop J-Series User Manual
Page 54

return 0;
}
Program Output:
WM_CREATE
The function call operator for
RWCString
has been overloaded to take an argument of type
RWCRegexp
. It returns an
RWCSubString
matching the expression, or the null substring if
there is no such expression.
Extended Regular Expressions
This version of the Tools.h++ class library supports extended regular expression searches based
on the POSIX.2 standard. (See the Bibliography.) Extended regular expressions are the regular
expressions used in the UNIX utilities lex and awk. You will find details of the regular
expression syntax in the Class Reference under
RWCRExpr
.
Note: RWCRExpr is available only if your compiler supports exception handling and the C++
Standard Library.
Extended regular expressions can be any length, although limited by available memory. You
can use parentheses to group subexpressions, and the symbol _ to create either/or regular
expressions for pattern matching.
The following example shows some of the capabilities of extended regular expressions:
#include "rw/rstream.h"
#include "rw/re.h"
main (){
RWCRExpr re("Lisa|Betty|Eliza");
RWCString s("Betty II is the Queen of England.");
s.replace(re, "Elizabeth");
cout << s << endl;
s = "Leg Leg Hurrah!";
re = "Leg";
s.replace(re, "Hip", RWCString::all);
cout << s << endl;
}
Program Output:
Elizabeth II is the Queen of England.
Hip Hip Hurrah!