2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
18 * This class (hopefully) makes it easy to use regular-expression pattern
19 * matching. As an example, you can do the following:
21 * LPREGEXP pExpr = new REGEXP (TEXT("sl[ia]p-h.ppy$"));
22 * if (pExpr->Matches (TEXT("slap-happy")))
24 * else if (pExpr->Matches (TEXT("slip-hoppy")))
26 * else if (!pExpr->Matches (TEXT("slug-hoppy")))
30 * As a convenience, you can also use a simpler, more limited interface...
32 * if (REGEXP::Matches (TEXT("sl[ia]p-h.ppy$"), TEXT("slug-hoppy")))
35 * You can also test a string to see if it looks like a regular expression:
37 * LPREGEXP pExpr = new REGEXP (TEXT("ab[cC]d"));
38 * if (pExpr->fIsRegExp())
40 * if (!REGEXP::fIsRegExp (TEXT("testing")))
46 * DEFINITIONS ________________________________________________________________
50 #define cchCOMPILED_BUFFER_MAX 512
51 #define nCOMPILED_PARENS_MAX 9 // "\1" through "\9"
53 typedef class EXPORTED REGEXP REGEXP, *LPREGEXP;
59 REGEXP (LPCTSTR pszExpr);
62 BOOL SetExpression (LPCTSTR pszExpr);
64 BOOL Matches (LPCTSTR pszString);
65 static BOOL Matches (LPCTSTR pszExpr, LPCTSTR pszString);
67 BOOL fIsRegExp (void);
68 static BOOL fIsRegExp (LPCTSTR pszExpr);
71 BOOL Compile (LPCTSTR pszExpr);
72 BOOL MatchSubset (LPCTSTR pszString, LPCTSTR pchCompiled, LPCTSTR *aParenStarts, LPCTSTR *aParenEnds);
73 BOOL CompareParen (int ii, LPCTSTR pszString, LPCTSTR *aParenStarts, LPCTSTR *aParenEnds);
74 BOOL fIsInCharSet (LPCTSTR pszCharSet, TCHAR chTest, int fInclusive);
76 BOOL m_fMatchFromStart;
77 TCHAR m_achCompiled[ cchCOMPILED_BUFFER_MAX ];