In file ../include/EST_Regex.h:

class EST_Regex

A Regular expression class to go with the CSTR EST_String class.

Inheritance:


Public Methods

[more] 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] Assignment

[more]EST_Regex& operator = (const EST_Regex ex)
[more]EST_Regex& operator = (const EST_String s)
[more]EST_Regex& operator = (const char* s)

Protected Methods

[more]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


Inherited from EST_String:

Public Fields

ostatic const char* version
ostatic const EST_String Empty

Split a string into parts.

[more]int max

Public Methods

oint length(void) const
oint space(void) const
oconst char* str(void) const
ochar* updatable_str(void)
ostatic EST_String FromChar(const char c)
ostatic EST_String Number(int i, int base=10)
ostatic EST_String Number(long i, int base=10)
ostatic EST_String Number(double d)
ostatic EST_String Number(float f)
oint Int(bool &ok) const
olong Long(bool &ok) const
ofloat Float(bool &ok) const
odouble Double(bool &ok) const

Before

[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

At

[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

After

[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

Search for something

[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

Get position of something

[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)

Does string contain something?

[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?

Does string exactly match?

[more]int matches(const char* e, int pos=0) const
Exatly match this string?
[more]int matches(const EST_String &e, int pos=0) const
Exatly 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

Global replacement

[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

Frequency counts

[more]int freq(const char* s) const
Number of occurances of substring
[more]int freq(const EST_String &s) const
Number of occurances of substring
[more]int freq(EST_Regex &s) const
Number of matches of regular expression

Quoting

[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 (eg.
[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

Operators

[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 char*()
Cast to char *, may involve copying
[more] Add to end of string.

[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] Asignment

[more]EST_String& operator = (const char* str)
Assign C string to EST_String
[more]EST_String& operator = (const char c)
Assign single character to EST_String
[more]EST_String& operator = (const EST_String &s)
Assign EST_String to EST_String

[more] Concatenation
[more] relational operators

[more]return b
[more] return(a==b)
[more]return compare(a, b)

String comparison.

[more]return compare(b, a)
[more] Case folded comparison.

[more]const EST_String& table return fcompare(a, b, (const unsigned char* )(const char* )table)

ostatic 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 )

Public

otypedef int EST_string_size
o#define MAX_STRING_SIZE(INT_MAX)


Documentation

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.

ovoid compile()
Compile expression

ovoid compile_match()
Compile expression in a form which only matches whole string

ochar* regularize(int match) const
Translate the expression into the internally used syntax

o EST_Regex(void)
Empty constructor, just for form

o EST_Regex(EST_String s)
Construct from EST_String

o EST_Regex(const char* ex)
Construct from C string

o EST_Regex(const EST_Regex &ex)
Copy constructor

o ~EST_Regex()
Destructor

oint size() const
Size of the expression

oint run(const char* on, int from, int &start, int &end, int* starts=NULL, int* ends=NULL)
Run to find a matching substring

oint run_match(const char* on, int from=0, int* starts=NULL, int* ends=NULL)
Run to see if it matches the entire string

oEST_String tostring(void) const
Get the expression as a string

o operator const char *() const
Cast operator, disambiguates it for some compilers

o Assignment

oEST_Regex& operator = (const EST_Regex ex)

oEST_Regex& operator = (const EST_String s)

oEST_Regex& operator = (const char* s)


This class has no child classes.
Friends:
ostream &operator << (ostream &s, const EST_Regex &str)
Author:
Richard Caley <rjc@cstr.ed.ac.uk> (regular expression library by Henry Spencer, University of Toronto)
Version:
See Also:
EST_String
string_example

Alphabetic index HTML hierarchy of classes or Java


This page is part of the Edinburgh Speech Tools Library documentation
Copyright University of Edinburgh 1997
Contact: speech_tools@cstr.ed.ac.uk