90 static const char *fsf_magic=
"^$*+?[].\\";
91 static const char *fsf_magic_backslashed=
"()|<>";
92 static const char *spencer_magic=
"^$*+?[].()|\\\n";
93 static const char *spencer_magic_backslashed=
"<>";
102 EST_Regex RXdouble(
"-?\\(\\([0-9]+\\.[0-9]*\\)\\|\\([0-9]+\\)\\|\\(\\.[0-9]+\\)\\)\\([eE][---+]?[0-9]+\\)?");
109 #if NSUBEXP != EST_Regex_max_subexpressions 110 # error "EST_Regex_max_subexpressions must be equal to NSUBEXP" 116 compiled_match =
NULL;
124 compiled_match =
NULL;
132 compiled_match =
NULL;
138 compiled_match =
NULL;
145 free(compiled_match);
159 int magic=0,last_was_bs=0;
160 const char * in_brackets=
NULL;
161 const char *ex = (
size()==0)?
"":
str();
163 if (match && *ex !=
'^')
168 if (*e ==
'\\' && !last_was_bs)
174 magic=strchr((last_was_bs?fsf_magic_backslashed:fsf_magic), *e)!=
NULL;
179 if (*e ==
']' && (e-in_brackets)>1)
184 if (strchr(spencer_magic_backslashed, *e))
193 if (strchr(spencer_magic, *e))
201 if (match && (e==ex || *(e-1) !=
'$'))
226 cerr <<
"EST_Regex: can't compile '" <<
str() <<
"'\n";
241 cerr <<
"EST_Regex: can't compile '" <<
str() <<
"'\n";
249 if (compiled && from <= strlen(on))
255 start = re->
startp[0] - on;
256 end = re->
endp[0]- on;
284 if (compiled_match && from <= strlen(on))
309 compiled_match =
NULL;
318 compiled_match =
NULL;
327 compiled_match =
NULL;
float end(const EST_Item &item)
#define walloc(TYPE, SIZE)
EST_String(void)
Construct an empty string.
A Regular expression class to go with the CSTR EST_String class.
friend ostream & operator<<(ostream &s, const EST_Regex &str)
Stream output of regular expression.
#define EST_Regex_max_subexpressions
EST_Regex RXdouble("-?\\(\\([0-9]+\\.[0-9]*\\)\\|\\([0-9]+\\)\\|\\(\\.[0-9]+\\)\\)\\([eE][---+]?[0-9]+\\)?")
Floating point number.
EST_Regex(void)
Empty constructor, just for form.
STATIC char * reg(int paren, int *flagp)
EST_Regex RXint("-?[0-9]+")
Integer.
EST_Regex RXuppercase("[A-Z]+")
Sequence of upper case alphabetic characters.
void compile_match()
Compile expression in a form which only matches whole string.
EST_Regex & operator=(const EST_Regex ex)
EST_Regex RXwhite("[ \n\t\r]+")
White space.
int run_match(const char *on, size_t from=0, size_t *starts=NULL, size_t *ends=NULL)
Run to see if it matches the entire string.
#define EST_STRING_ERR_IDX
hs_regexp * hs_regcomp(const char *exp)
EST_Regex RXidentifier("[A-Za-z_][0-9A-Za-z_]+")
Initial letter or underscore followed by letters underscores or digits.
EST_Regex RXlowercase("[a-z]+")
Sequence of lower case alphabetic characters.
EST_Regex RXalpha("[A-Za-z]+")
Sequence of alphabetic characters.
char * regularize(int match) const
Translate the expression into the internally used syntax.
int hs_regexec(const hs_regexp *prog, const char *string)
void compile()
Compile expression.
float start(const EST_Item &item)
const char * str(void) const
Get a const-pointer to the actual memory.
EST_Regex RXalphanum("[0-9A-Za-z]+")
Sequence of letters and/or digits.
int run(const char *on, size_t from, size_t &start, size_t &end, size_t *starts=NULL, size_t *ends=NULL)
Run to find a matching substring.
int size() const
Size of the expression.