Logo Search packages:      
Sourcecode: speech-tools version File versions  Download package

EST_Regex Class Reference

#include <EST_Regex.h>

Inheritance diagram for EST_Regex:

EST_String

List of all members.


Detailed Description

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.

See also:
EST_String

string_example

Author:
Richard Caley <rjc@cstr.ed.ac.uk>

(regular expression library by Henry Spencer, University of Toronto)

Version:
Id
EST_Regex.h,v 1.2 2001/04/04 13:11:27 awb Exp

Definition at line 55 of file EST_Regex.h.


Public Member Functions

 EST_Regex (const EST_Regex &ex)
 Copy constructor.
 EST_Regex (const char *ex)
 Construct from C string.
 EST_Regex (EST_String s)
 Construct from EST_String.
 EST_Regex (void)
 Empty constructor, just for form.
 operator const char * () const
 Cast operator, disambiguates it for some compilers.
int operator!= (const EST_Regex ex) const
int operator== (const EST_Regex ex) const
int run (const char *on, int from, int &start, int &end, int *starts=NULL, int *ends=NULL)
 Run to find a matching substring.
int run_match (const char *on, int from=0, int *starts=NULL, int *ends=NULL)
 Run to see if it matches the entire string.
int size () const
 Size of the expression.
EST_String tostring (void) const
 Get the expression as a string.
 ~EST_Regex ()
 Destructor.
Assignment
EST_Regexoperator= (const char *s)
 Assign C string to EST_String.
EST_Regexoperator= (const EST_String s)
EST_Regexoperator= (const EST_Regex ex)

Protected Types

typedef int EST_string_size
 Type of string size field.

Protected Member Functions

void compile ()
 Compile expression.
void compile_match ()
 Compile expression in a form which only matches whole string.
double Double (void) const
double Double (bool &ok) const
 Convert to a double.
float Float (void) const
float Float (bool &ok) const
 Convert to a float.
EST_Stringignore_volatile (void) volatile
int Int (void) const
int Int (bool &ok) const
 Convert to an integer.
int length (void) const
 Length of string ({not} length of underlying chunk).
long Long (void) const
long Long (bool &ok) const
 Convert to a long.
void make_updatable (void)
char * regularize (int match) const
 Translate the expression into the internally used syntax.
int space (void) const
 Size of underlying chunk.
const char * str (void) const
 Get a const-pointer to the actual memory.
char * updatable_str (void)
 Get a writable pointer to the actual memory.
After
EST_String after (EST_Regex &e, int pos=0) const
 Part after match of regular expression.
EST_String after (const EST_String &s, int pos=0) const
 Part after substring.
EST_String after (const char *s, int pos=0) const
 Part after substring.
EST_String after (int pos, int len=1) const
 Part after pos+len.
At
EST_String at (EST_Regex &e, int pos=0) const
 Return part matching regexp.
EST_String at (const EST_String &s, int pos=0) const
 Return part where substring found (not useful, included for completeness).
EST_String at (const char *s, int pos=0) const
 Return part where substring found (not useful, included for completeness).
EST_String at (int from, int len=0) const
 Return part at position.
Before
EST_String before (EST_Regex &e, int pos=0) const
 Part before first match of regexp after pos.
EST_String before (const EST_String &s, int pos=0) const
 Part before first matching substring after pos.
EST_String before (const char *s, int pos=0) const
 Part before first matching substring after pos.
EST_String before (int pos, int len=0) const
 Part before position.
Does string contain something?
int contains (EST_Regex &ex, int pos=-1) const
 Does it contain a match for this regular expression?
int contains (const char c, int pos=-1) const
 Does it contain this character?
int contains (const EST_String &s, int pos=-1) const
 Does it contain this substring?
int contains (const char *s, int pos=-1) const
 Does it contain this substring?
Frequency counts
int freq (EST_Regex &s) const
 Number of matches of regular expression.
int freq (const EST_String &s) const
 Number of occurances of substring.
int freq (const char *s) const
 Number of occurances of substring.
Global replacement
int gsub (EST_Regex &ex, int bracket_num)
 Substitute string for matches of regular expression.
int gsub (EST_Regex &ex, const char *s)
 Substitute string for matches of regular expression.
int gsub (EST_Regex &ex, const EST_String &s)
 Substitute string for matches of regular expression.
int gsub (const EST_String &os, const char *s)
 Substitute one string for another.
int gsub (const EST_String &os, const EST_String &s)
 Substitute one string for another.
int gsub (const char *os, const char *s)
 Substitute one string for another.
int gsub (const char *os, const EST_String &s)
 Substitute one string for another.
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.
Get position of something
int index (EST_Regex &ex, int pos=0) const
 Position of match of regexp (starting at pos).
int index (const EST_String &s, int pos=0) const
 Position of substring (starting at pos).
int index (const char *s, int pos=0) const
 Position of substring (starting at pos).
Does string exactly match?
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.
int matches (const EST_String &e, int pos=0) const
 Exatly match this string?
int matches (const char *e, int pos=0) const
 Exatly match this string?
Operators
 operator char * ()
 Cast to char *, may involve copying.
 operator const char * ()
const char operator() (int i) const
 Function style access to constant strings.
char & operator[] (int i)
 Array style access to writable strings.
Add to end of string.
EST_Stringoperator+= (const EST_String b)
 Add EST_String to end of EST_String.
EST_Stringoperator+= (const char *b)
 Add C string to end of EST_String.
Quoting
EST_String quote (const char quotec) const
 Return the string in quotes with internal quotes protected.
EST_String quote_if_needed (const char quotec) const
 Return in quotes if there is something to protect (e.g. spaces).
EST_String unquote (const char quotec) const
 Remove quotes and unprotect internal quotes.
EST_String unquote_if_needed (const char quotec) const
 Remove quotes if any.
Search for something
int search (EST_Regex &re, int &mlen, int pos=0, int *starts=NULL, int *ends=NULL) const
 Find a match of the regular expression.
int search (const EST_String s, int &mlen, int pos=0) const
 Find a substring.
int search (const char *s, int len, int &mlen, int pos=0) const
 Find a substring.

Static Protected Member Functions

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.
static EST_String Number (float f)
 Build string from a float.
static EST_String Number (double d)
 Build string from a double.
static EST_String Number (long i, int base=10)
 Build string from a long integer.
static EST_String Number (int i, int base=10)
 Build string from an integer.

Static Protected Attributes

static const EST_String Empty
 Constant empty string.
static const char * version = "CSTR String Class " STRING_VERSION " " STRING_DATE
 Global version string.

Private Attributes

void * compiled
 The compiled form.
void * compiled_match
 Compiled form for whole string match.

Friends

EST_String downcase (const EST_String &s)
 Convert to lower case.
class EST_Regex
EST_String operator* (const EST_String &s, int n)
 Repeat string N times.
ostream & operator<< (ostream &s, const EST_String &str)
 Stream output for EST_String.
ostream & operator<< (ostream &s, const EST_Regex &str)
 Stream output of regular expression.
EST_String upcase (const EST_String &s)
 Convert to upper case.
String comparison.
All these operators return -1, 0 or 1 to indicate the sort order of the strings.

int compare (const char *a, const EST_String &b)
int compare (const EST_String &a, const char *b)
int compare (const EST_String &a, const EST_String &b)
int fcompare (const EST_String &a, const EST_String &b, const EST_String &table)
int fcompare (const EST_String &a, const char *b, const unsigned char *table=NULL)
int fcompare (const EST_String &a, const EST_String &b, const unsigned char *table=NULL)
relational operators
int operator!= (const EST_String &a, const EST_String &b)
int operator!= (const EST_String &a, const char *b)
int operator!= (const char *a, const EST_String &b)
int operator< (const EST_String &a, const EST_String &b)
int operator< (const EST_String &a, const char *b)
int operator< (const char *a, const EST_String &b)
int operator<= (const EST_String &a, const EST_String &b)
int operator<= (const EST_String &a, const char *b)
int operator<= (const char *a, const EST_String &b)
int operator== (const EST_String &a, const EST_String &b)
int operator== (const EST_String &a, const char *b)
int operator== (const char *a, const EST_String &b)
int operator> (const EST_String &a, const EST_String &b)
int operator> (const EST_String &a, const char *b)
int operator> (const char *a, const EST_String &b)
int operator>= (const EST_String &a, const EST_String &b)
int operator>= (const EST_String &a, const char *b)
int operator>= (const char *a, const EST_String &b)
Concatenation
EST_String operator+ (const EST_String &a, const char *b)
 Concatenate EST_String with C String.
EST_String operator+ (const char *a, const EST_String &b)
 Concatenate C String with EST_String.
EST_String operator+ (const EST_String &a, const EST_String &b)
 Concatenate two EST_Strings.
Split a string into parts.
These functions divide up a string producing an array of substrings.

int split (const EST_String &s, EST_String result[], int max, EST_Regex &seperator, char quote=0)
 Split at each match of the regular expression.
int split (const EST_String &s, EST_String result[], int max, const char *seperator, char quote=0)
 Split at a given separator.
int split (const EST_String &s, EST_String result[], int max, const EST_String &seperator, char quote=0)
 Split at a given separator.

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index