ROOT 6.14/05 Reference Guide |
A regular expression, often called a pattern, is an expression that describes a set of strings.
They are usually used to give a concise description of a set, without having to list all elements. The Unix utilities like sed and grep make extensive use of regular expressions. Scripting languages like Perl have regular expression engines built directly into their syntax .
Extensive documentation about Regular expressions in Perl can be found at: http://perldoc.perl.org/perlre.html
ROOT has this capability through the use of the P(erl) C(ompatible) R(egular) E(xpression)
Its functionality can be accessed through the TPRegexp and TString class . Note that in patterns taken from Perl all backslash character have to be replaced in the C/C++ strings by two backslashes .
This macro shows several ways how to use the Match/Substitute capabilities of the the TPRegexp class . It can be run as follows :
Definition in file regexp.C.