#include <cel_regex.h>
Public Member Functions | |
| RegularExpression (const UChar1 *inPattern, int inOptionFlags=regex_default) | |
| RegularExpression (const String &inPattern, int inOptionFlags=regex_default) | |
| RegularExpression (const utf8s &inPattern, int inOptionFlags=regex_default) | |
| void | init (const UChar1 *inPattern, int inOptionFlags=regex_default) |
| bool | findFirst (const String &str) |
| bool | findFirst (const UChar1 *str, const UChar1 *rangePtr=NULL, const UChar1 *rangeEnd=NULL, const UChar1 *strEnd=NULL) |
| bool | findNext () |
| bool | isVaild () const |
| size_t | getCount () const |
| size_t | getPos (size_t n=0) const |
| size_t | getEndPos (size_t n=0) const |
| size_t | getLength (size_t n=0) const |
| const UChar1 * | getPtr (size_t n=0) const |
| String | getString (size_t n=0) const |
The following is the sample code of using RegularExpression class.
void enumerate_URLs(const String& inText) { // This regular expression separates the URL into parts. RegularExpression reUrl( utf8s( "(\\w+[\\w-]+\\w+):\\/\\/" // "scheme://" "(?:([^\\:]+)(?:\\:(\\w+))?\\@)?+" // "user:pass@" "([^/:]+)" // "hostname" "(?::(\\d*))?" // ":111" "([^#\\?\\s]*)" // "/foo/bar/test.txt" "(\\S*)")); // "?foo=1&bar=2" or "#label" if(!reUrl.findFirst(inText)) { // There's no match in the string return; } do { printf( "URL : \"%s\"\n" "Scheme : \"%s\"\n" "Username: \"%s\"\n" "Password: \"%s\"\n" "Hostname: \"%s\"\n" "Port : %s\n" "Path : \"%s\"\n" "Extra : \"%s\"\n", TO_MBS(reUrl.getString(0)), TO_MBS(reUrl.getString(1)), TO_MBS(reUrl.getString(2)), TO_MBS(reUrl.getString(3)), TO_MBS(reUrl.getString(4)), reUrl.getString(5), TO_MBS(reUrl.getString(6)), TO_MBS(reUrl.getString(7))); } while(reUrl.findnext());
Definition at line 142 of file cel_regex.h.
| Celartem::RegularExpression::RegularExpression | ( | const UChar1 * | inPattern, | |
| int | inOptionFlags = regex_default | |||
| ) | [inline] |
This method create a RegularExpression instance.
| inPattern | A pattern to search. | |
| inOptionFlags | Any combination of RegexOptionFlag enumerations to control the behavior. |
Definition at line 153 of file cel_regex.h.
| Celartem::RegularExpression::RegularExpression | ( | const String & | inPattern, | |
| int | inOptionFlags = regex_default | |||
| ) | [inline] |
This method create a RegularExpression instance.
| inPattern | A pattern to search. | |
| inOptionFlags | Any combination of RegexOptionFlag enumerations to control the behavior. |
Definition at line 168 of file cel_regex.h.
| Celartem::RegularExpression::RegularExpression | ( | const utf8s & | inPattern, | |
| int | inOptionFlags = regex_default | |||
| ) | [inline] |
This method create a RegularExpression instance.
| inPattern | A pattern to search. | |
| inOptionFlags | Any combination of RegexOptionFlag enumerations to control the behavior. |
Definition at line 185 of file cel_regex.h.
| void Celartem::RegularExpression::init | ( | const UChar1 * | inPattern, | |
| int | inOptionFlags = regex_default | |||
| ) | [inline] |
This method re-initializes the instance to search another pattern.
| inPattern | A pattern to search. | |
| inOptionFlags | Any combination of RegexOptionFlag enumerations to control the behavior. |
Definition at line 200 of file cel_regex.h.
Referenced by RegularExpression().
| bool Celartem::RegularExpression::findFirst | ( | const String & | str | ) | [inline] |
This method begins a new search in the specified string.
| str | The string on which the new search starts. |
true if at least one matching portion is found, otherwise false. Definition at line 216 of file cel_regex.h.
| bool Celartem::RegularExpression::findFirst | ( | const UChar1 * | str, | |
| const UChar1 * | rangePtr = NULL, |
|||
| const UChar1 * | rangeEnd = NULL, |
|||
| const UChar1 * | strEnd = NULL | |||
| ) | [inline] |
This method begins a new search in the specified string.
| str | A string to do pattern matching on. | |
| rangePtr | Pointer to the beginning point of pattern matching. | |
| rangeEnd | Pointer to the ending point of pattern matching. | |
| strEnd | Pointer to the string end. If this parameter is explicitly specified, then str don't have to be terminated by '\0'. |
true if at least one matching portion is found, otherwise false. Definition at line 239 of file cel_regex.h.
| bool Celartem::RegularExpression::findNext | ( | ) | [inline] |
This method returns the next matching portion if available.
true if at least one more matching portion is found, otherwise false. Definition at line 255 of file cel_regex.h.
| bool Celartem::RegularExpression::isVaild | ( | ) | const [inline] |
This method verifies whether the last match is valid or not.
true if valid, otherwise false. Definition at line 274 of file cel_regex.h.
| size_t Celartem::RegularExpression::getCount | ( | ) | const [inline] |
This method returns the count of the portions stored in this instance.
Definition at line 285 of file cel_regex.h.
| size_t Celartem::RegularExpression::getPos | ( | size_t | n = 0 |
) | const [inline] |
This method returns the beginning position of the specified portion.
| n | The index of the portion. |
Definition at line 298 of file cel_regex.h.
| size_t Celartem::RegularExpression::getEndPos | ( | size_t | n = 0 |
) | const [inline] |
This method returns the ending position of the specified portion.
| n | The index of the portion. |
Definition at line 311 of file cel_regex.h.
| size_t Celartem::RegularExpression::getLength | ( | size_t | n = 0 |
) | const [inline] |
This method returns the length of the specified portion.
| n | The index of the portion. |
Definition at line 323 of file cel_regex.h.
| const UChar1* Celartem::RegularExpression::getPtr | ( | size_t | n = 0 |
) | const [inline] |
This method returns the pointer to the specified portion.
| n | The index of the portion. |
Definition at line 335 of file cel_regex.h.
| String Celartem::RegularExpression::getString | ( | size_t | n = 0 |
) | const [inline] |
This method returns the string of the specified portion.
| n | The index of the portion. |
Definition at line 347 of file cel_regex.h.