#include <include/EST_Regex.h>
Public Member Functions | |
EST_Regex (void) | |
Empty constructor, just for form. More... | |
EST_Regex (EST_String s) | |
Construct from EST_String. More... | |
EST_Regex (const char *ex) | |
Construct from C string. More... | |
EST_Regex (const EST_Regex &ex) | |
Copy constructor. More... | |
~EST_Regex () | |
Destructor. More... | |
int | size () const |
Size of the expression. More... | |
int | run (const char *on, int from, int &start, int &end, int *starts=NULL, int *ends=NULL) |
Run to find a matching substring. More... | |
int | run_match (const char *on, int from=0, int *starts=NULL, int *ends=NULL) |
Run to see if it matches the entire string. More... | |
EST_String | tostring (void) const |
Get the expression as a string. More... | |
operator const char * () const | |
Cast operator, disambiguates it for some compilers. More... | |
int | operator== (const EST_Regex ex) const |
int | operator!= (const EST_Regex ex) const |
Protected Member Functions | |
void | compile () |
Compile expression. More... | |
void | compile_match () |
Compile expression in a form which only matches whole string. More... | |
char * | regularize (int match) const |
Translate the expression into the internally used syntax. More... | |
![]() | |
EST_String | before (int pos, int len=0) const |
Part before position. More... | |
EST_String | before (const char *s, int pos=0) const |
Part before first matching substring after pos. More... | |
EST_String | before (const EST_String &s, int pos=0) const |
Part before first matching substring after pos. More... | |
EST_String | before (EST_Regex &e, int pos=0) const |
Part before first match of regexp after pos. More... | |
EST_String | at (int from, int len=0) const |
Return part at position. More... | |
EST_String | at (const char *s, int pos=0) const |
Return part where substring found (not useful, included for completeness) More... | |
EST_String | at (const EST_String &s, int pos=0) const |
Return part where substring found (not useful, included for completeness) More... | |
EST_String | at (EST_Regex &e, int pos=0) const |
Return part matching regexp. More... | |
EST_String | after (int pos, int len=1) const |
Part after pos+len. More... | |
EST_String | after (const char *s, int pos=0) const |
Part after substring. More... | |
EST_String | after (const EST_String &s, int pos=0) const |
Part after substring. More... | |
EST_String | after (EST_Regex &e, int pos=0) const |
Part after match of regular expression. More... | |
int | search (const char *s, int len, int &mlen, int pos=0) const |
Find a substring. More... | |
int | search (const EST_String s, int &mlen, int pos=0) const |
Find a substring. More... | |
int | search (EST_Regex &re, int &mlen, int pos=0, int *starts=NULL, int *ends=NULL) const |
Find a match of the regular expression. More... | |
int | index (const char *s, int pos=0) const |
Position of substring (starting at pos) More... | |
int | index (const EST_String &s, int pos=0) const |
Position of substring (starting at pos) More... | |
int | index (EST_Regex &ex, int pos=0) const |
Position of match of regexp (starting at pos) More... | |
int | contains (const char *s, int pos=-1) const |
Does it contain this substring? More... | |
int | contains (const EST_String &s, int pos=-1) const |
Does it contain this substring? More... | |
int | contains (const char c, int pos=-1) const |
Does it contain this character? More... | |
int | contains (EST_Regex &ex, int pos=-1) const |
Does it contain a match for this regular expression? More... | |
int | matches (const char *e, int pos=0) const |
Exactly match this string? More... | |
int | matches (const EST_String &e, int pos=0) const |
Exactly match this string? More... | |
int | matches (EST_Regex &e, int pos=0, int *starts=NULL, int *ends=NULL) const |
Exactly matches this regular expression, can return ends of sub-expressions. More... | |
int | gsub (const char *os, const EST_String &s) |
Substitute one string for another. More... | |
int | gsub (const char *os, const char *s) |
Substitute one string for another. More... | |
int | gsub (const EST_String &os, const EST_String &s) |
Substitute one string for another. More... | |
int | gsub (const EST_String &os, const char *s) |
Substitute one string for another. More... | |
int | gsub (EST_Regex &ex, const EST_String &s) |
Substitute string for matches of regular expression. More... | |
int | gsub (EST_Regex &ex, const char *s) |
Substitute string for matches of regular expression. More... | |
int | gsub (EST_Regex &ex, int bracket_num) |
Substitute string for matches of regular expression. More... | |
int | subst (EST_String source, int(&starts)[EST_Regex_max_subexpressions], int(&ends)[EST_Regex_max_subexpressions]) |
Substitute the result of a match into a string. More... | |
int | freq (const char *s) const |
Number of occurrences of substring. More... | |
int | freq (const EST_String &s) const |
Number of occurrences of substring. More... | |
int | freq (EST_Regex &s) const |
Number of matches of regular expression. More... | |
EST_String | quote (const char quotec) const |
Return the string in quotes with internal quotes protected. More... | |
EST_String | quote_if_needed (const char quotec) const |
Return in quotes if there is something to protect (e.g. spaces) More... | |
EST_String | unquote (const char quotec) const |
Remove quotes and unprotect internal quotes. More... | |
EST_String | unquote_if_needed (const char quotec) const |
Remove quotes if any. More... | |
const char | operator() (int i) const |
Function style access to constant strings. More... | |
char & | operator[] (int i) |
Array style access to writable strings. More... | |
operator const char * () const | |
Cast to const char * by simply giving access to pointer. More... | |
operator const char * () | |
operator char * () | |
Cast to char *, may involve copying. More... | |
EST_String & | operator+= (const char *b) |
Add C string to end of EST_String. More... | |
EST_String & | operator+= (const EST_String b) |
Add EST_String to end of EST_String. More... | |
EST_String & | operator= (const char *str) |
Assign C string to EST_String. More... | |
EST_String & | ignore_volatile (void) volatile |
EST_String (void) | |
Construct an empty string. More... | |
EST_String (const char *s) | |
Construct from char *. More... | |
EST_String (const char *s, int start_or_fill, int len) | |
Construct from part of char * or fill with given character. More... | |
EST_String (const char *s, int s_size, int start, int len) | |
Construct from C string. More... | |
EST_String (const EST_String &s, int start, int len) | |
~EST_String () | |
Destructor. More... | |
int | length (void) const |
Length of string ({not} length of underlying chunk) More... | |
int | space (void) const |
Size of underlying chunk. More... | |
const char * | str (void) const |
Get a const-pointer to the actual memory. More... | |
char * | updatable_str (void) |
Get a writable pointer to the actual memory. More... | |
void | make_updatable (void) |
int | Int (bool &ok) const |
Convert to an integer. More... | |
int | Int (void) const |
long | Long (bool &ok) const |
Convert to a long. More... | |
long | Long (void) const |
float | Float (bool &ok) const |
Convert to a float. More... | |
float | Float (void) const |
double | Double (bool &ok) const |
Convert to a double. More... | |
double | Double (void) const |
Assignment | |
EST_Regex & | operator= (const EST_Regex ex) |
EST_Regex & | operator= (const EST_String s) |
EST_Regex & | operator= (const char *s) |
ostream & | operator<< (ostream &s, const EST_Regex &str) |
Stream output of regular expression. More... | |
Additional Inherited Members | |
![]() | |
typedef int | EST_string_size |
Type of string size field. More... | |
![]() | |
static EST_String | cat (const EST_String s1, const EST_String s2=Empty, const EST_String s3=Empty, const EST_String s4=Empty, const EST_String s5=Empty, const EST_String s6=Empty, const EST_String s7=Empty, const EST_String s8=Empty, const EST_String s9=Empty) |
static EST_String | FromChar (const char c) |
Build string from a single character. More... | |
static EST_String | Number (int i, int base=10) |
Build string from an integer. More... | |
static EST_String | Number (long i, int base=10) |
Build string from a long integer. More... | |
static EST_String | Number (double d) |
Build string from a double. More... | |
static EST_String | Number (float f) |
Build string from a float. More... | |
![]() | |
static const char * | version = "CSTR String Class " STRING_VERSION " " STRING_DATE |
Global version string. More... | |
static const EST_String | Empty |
Constant empty string. More... | |
A Regular expression class to go with the CSTR EST_String class.
The regular expression syntax is the FSF syntax used in emacs and in the FSF String library. This is translated into the syntax supported by Henry Spensor's regular expression library, this translation is a place to look if you find regular expressions not matching where expected.
Definition at line 55 of file EST_Regex.h.
EST_Regex::EST_Regex | ( | void | ) |
Empty constructor, just for form.
Definition at line 111 of file EST_Regex.cc.
EST_Regex::EST_Regex | ( | EST_String | s | ) |
Construct from EST_String.
Definition at line 126 of file EST_Regex.cc.
EST_Regex::EST_Regex | ( | const char * | ex | ) |
Construct from C string.
Definition at line 117 of file EST_Regex.cc.
EST_Regex::EST_Regex | ( | const EST_Regex & | ex | ) |
Copy constructor.
Definition at line 133 of file EST_Regex.cc.
EST_Regex::~EST_Regex | ( | ) |
Destructor.
Definition at line 140 of file EST_Regex.cc.
|
protected |
Compile expression.
Definition at line 213 of file EST_Regex.cc.
|
protected |
Compile expression in a form which only matches whole string.
Definition at line 227 of file EST_Regex.cc.
|
protected |
Translate the expression into the internally used syntax.
Definition at line 152 of file EST_Regex.cc.
|
inline |
Size of the expression.
Definition at line 88 of file EST_Regex.h.
int EST_Regex::run | ( | const char * | on, |
int | from, | ||
int & | start, | ||
int & | end, | ||
int * | starts = NULL , |
||
int * | ends = NULL |
||
) |
Run to find a matching substring.
Definition at line 242 of file EST_Regex.cc.
int EST_Regex::run_match | ( | const char * | on, |
int | from = 0 , |
||
int * | starts = NULL , |
||
int * | ends = NULL |
||
) |
Run to see if it matches the entire string.
Definition at line 275 of file EST_Regex.cc.
|
inline |
Get the expression as a string.
Definition at line 96 of file EST_Regex.h.
|
inline |
Cast operator, disambiguates it for some compilers.
Definition at line 99 of file EST_Regex.h.
|
inline |
Definition at line 101 of file EST_Regex.h.
|
inline |
Definition at line 104 of file EST_Regex.h.
Definition at line 303 of file EST_Regex.cc.
EST_Regex & EST_Regex::operator= | ( | const EST_String | s | ) |
Definition at line 312 of file EST_Regex.cc.
EST_Regex & EST_Regex::operator= | ( | const char * | s | ) |
Definition at line 321 of file EST_Regex.cc.
|
friend |
Stream output of regular expression.
Definition at line 330 of file EST_Regex.cc.