Homer Library
RegularExpression


The regular expression syntax which I have used in my add-ons is the EXTENDED_POSIX_SYNTAX:


RegularExpression::RegularExpression(const char* regex, RegexSyntax = EXTENDED_POSIX_SYNTAX, bool = false);

This constructs the regular expression regex given as a string. You can optionally specify the particular syntax of regex among the following set:

An additional flag (ICASE_SYNTAX) can be used to specify that the regular expression is case insensitive.
The optional third parameter is used to make the regular expression match faster by allocating a fast map.
Be sure to check the result of the construction with RegularExpression::InitCheck().

See also RegularExpression::CompileFastMap().
See also the SetCaseSensitive(), SetCaseInsensitive() and   SetTranslation() methods


RegularExpression::~RegularExpression();

frees internal stuff


status_t InitCheck() const;

Returns whether the regular expression has successfully been compiled (B_OK) or not (B_BAD_VALUE). B_BAD_VALUE can also be returned if the fast map could not be compiled (if requested).


bool CompileFastMap();

Returns whether the fast map was or has just been successfully compiled (true) or not (false).


void SetTranslation(const char c1, const char c2, uint32 length = 1);
void UnsetTranslation();

These methods are used to set or unset the translation table used by the regular expression. Basically, it is an array which is used to translate the input characters and implement case sensitiveness. However, you can use this table to set any kind of translation.

SetTranslation set the translation for characters c1 to c1+length to c2 to c2+length. For instance:

SetTranslation('A', 'a', uint32('z'-'a'+1));

sets the regular expression case sensitive, and

SetTranslation('a', 'a', uint32('z'-'a'+1));

sets the regular expression case insensitive.
However, you should stick with the SetCaseSensitive() and SetCaseInsensitive() methods when it comes to case sensitiveness.


void SetCaseSensitive();
void
SetCaseInsensitive();

These methods are used to set the case sensitiveness of the regular expressions. Basically, they set the translation table by calling the SetTranslation method. Note that the translation map is only affected for alphabetical characters if a translation map exists.


This page was last updated on 12/12/99.