public Regex Regex( string pattern, RegexOptions options ) { var key = string.Format( CultureInfo.InvariantCulture, "{0}:{1}", pattern.GetHashCode(), options.GetHashCode() ); if ( cache.ContainsKey( key ) ) { return cache[key]; } var regex = new Regex( pattern, options ); cache.Add( key, regex ); return regex; }
public Regex Regex(string pattern, RegexOptions options) { var key = string.Format(CultureInfo.InvariantCulture, "{0}:{1}", pattern.GetHashCode(), options.GetHashCode()); if (cache.ContainsKey(key)) { return(cache[key]); } var regex = new Regex(pattern, options); cache.Add(key, regex); return(regex); }