00001 // This may look like C code, but it is really -*- C++ -*- 00002 /* 00003 Copyright (C) 1988 Free Software Foundation 00004 written by Doug Lea (dl@rocky.oswego.edu) 00005 00006 This file is part of the GNU C++ Library. This library is free 00007 software; you can redistribute it and/or modify it under the terms of 00008 the GNU Library General Public License as published by the Free 00009 Software Foundation; either version 2 of the License, or (at your 00010 option) any later version. This library is distributed in the hope 00011 that it will be useful, but WITHOUT ANY WARRANTY; without even the 00012 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00013 PURPOSE. See the GNU Library General Public License for more details. 00014 You should have received a copy of the GNU Library General Public 00015 License along with this library; if not, write to the Free Software 00016 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 */ 00018 00019 00020 #ifndef _Regex_h 00021 #define _Regex_h 1 00022 00023 #undef OK 00024 #include <string.h> 00025 #include <regex.h> 00026 00027 class Regex 00028 { 00029 private: 00030 00031 Regex(const Regex&) {} // no X(X&) 00032 void operator = (const Regex&) {} // no assignment 00033 00034 protected: 00035 regex_t preg; 00036 static const int maxMatch = 10; 00037 regmatch_t *rmatch; 00038 public: 00039 /* 00040 Regex(const char* t, 00041 int fast = 0, 00042 int bufsize = 40, 00043 const char* transtable = 0); 00044 */ 00045 Regex( const char* t ); 00046 ~Regex(); 00047 00048 int match(const char* s, int len, int pos = 0) const; 00049 int search(const char* s, int len, 00050 int& matchlen, int startpos = 0) const; 00051 int match_info(int& start, int& length, int nth = 0) const; 00052 00053 }; 00054 00055 // some built in regular expressions 00056 00057 extern const Regex RXwhite; // = "[ \n\t\r\v\f]+" 00058 extern const Regex RXint; // = "-?[0-9]+" 00059 extern const Regex RXdouble; // = "-?\\(\\([0-9]+\\.[0-9]*\\)\\| 00060 // \\([0-9]+\\)\\|\\(\\.[0-9]+\\)\\) 00061 // \\([eE][---+]?[0-9]+\\)?" 00062 extern const Regex RXalpha; // = "[A-Za-z]+" 00063 extern const Regex RXlowercase; // = "[a-z]+" 00064 extern const Regex RXuppercase; // = "[A-Z]+" 00065 extern const Regex RXalphanum; // = "[0-9A-Za-z]+" 00066 extern const Regex RXidentifier; // = "[A-Za-z_][A-Za-z0-9_]*" 00067 00068 00069 #endif