// "State changing" // Set the mode to use public bool SetMode(ktRE_Mode Mode) { m_Mode = Mode; return true; }
// Constructors... // Main Constructor (takes both pattern and mode) public ktRegEx(ktString Pattern, ktRE_Mode Mode) : base("ktRegEx", 0) { SetMode(Mode); SetPattern(Pattern); }
// Constructor that only takes mode (wrapper for main constructor) public ktRegEx(ktRE_Mode Mode) : this("", Mode) { }
// Clear the state/settings (mode, pattern etc.) public void Clear() { // Clear the patterns etc.. m_P = null; m_Pattern.Clear(); m_Mode = 0; }
// Match a pattern against a value (static!) public static bool Matches(ktString Pattern, ktString Value, ktRE_Mode Mode) { // "Init" the object Regex RegObj; // Check which mode to use // If we should use the mode "plain" if (Mode == ktRE_Mode.Plain) { // Create the (internal) regex object using the givven pattern RegObj = new Regex(Pattern.GetValue()); // Doesn't support the mode for now } else { // We set an error that we doesn't support the choosed mode // (should we throw and exception???) /*SetError( "ktRegExp::Match() : The mode '" + GetModeAsString().GetValue() + "' is not implementet yet!", ktERR.NOTIMP );*/ return false; } // Do the match... return RegObj.IsMatch(Value.GetValue()); }
public static ktRE_Match Match(ktString Haystack, ktString Value, ktRE_Mode Mode) { ktRegEx RE = new ktRegEx(Value, Mode); return RE.Match(Haystack); }
public static ktString GetModeAsString(ktRE_Mode Mode) { ktString ModeStr = new ktString(); if (Mode == ktRE_Mode.Signs) ModeStr = "ktRE_Mode.Signs"; else if (Mode == ktRE_Mode.Plain) ModeStr = "ktRE_Mode.Plain"; else if (Mode == ktRE_Mode.PERL) ModeStr = "ktRE_Mode.PERL"; return ModeStr; }
public static int Find(ktString Haystack, ktString Value, ktRE_Mode Mode) { ktRegEx RE = new ktRegEx(Value, Mode); return RE.Find(Haystack); }