private IntegerExtractor(string placeholder = NumbersDefinitions.PlaceHolderDefault) { this.Regexes = new Dictionary <Regex, TypeTag> { { RegexCache.Get(NumbersDefinitions.NumbersWithPlaceHolder(placeholder), RegexFlags), RegexTagGenerator.GenerateRegexTag(Constants.INTEGER_PREFIX, Constants.NUMBER_SUFFIX) }, { RegexCache.Get(NumbersDefinitions.NumbersWithSuffix, RegexFlags), RegexTagGenerator.GenerateRegexTag(Constants.INTEGER_PREFIX, Constants.NUMBER_SUFFIX) }, { GenerateLongFormatNumberRegexes(LongFormatType.IntegerNumDot, placeholder), RegexTagGenerator.GenerateRegexTag(Constants.INTEGER_PREFIX, Constants.NUMBER_SUFFIX) }, { RegexCache.Get(NumbersDefinitions.RoundNumberIntegerRegexWithLocks, RegexFlags), RegexTagGenerator.GenerateRegexTag(Constants.INTEGER_PREFIX, Constants.NUMBER_SUFFIX) }, { RegexCache.Get(NumbersDefinitions.NumbersWithDozenSuffix, RegexFlags), RegexTagGenerator.GenerateRegexTag(Constants.INTEGER_PREFIX, Constants.NUMBER_SUFFIX) }, { RegexCache.Get(NumbersDefinitions.AllIntRegexWithLocks, RegexFlags), RegexTagGenerator.GenerateRegexTag(Constants.INTEGER_PREFIX, Constants.ITALIAN) }, { RegexCache.Get(NumbersDefinitions.AllIntRegexWithDozenSuffixLocks, RegexFlags), RegexTagGenerator.GenerateRegexTag(Constants.INTEGER_PREFIX, Constants.ITALIAN) }, { GenerateLongFormatNumberRegexes(LongFormatType.IntegerNumBlank, placeholder), RegexTagGenerator.GenerateRegexTag(Constants.INTEGER_PREFIX, Constants.NUMBER_SUFFIX) }, { GenerateLongFormatNumberRegexes(LongFormatType.IntegerNumNoBreakSpace, placeholder), RegexTagGenerator.GenerateRegexTag(Constants.INTEGER_PREFIX, Constants.NUMBER_SUFFIX) }, }.ToImmutableDictionary(); }
public JapaneseTimeExtractorConfiguration() { var regexes = new Dictionary <Regex, TimeType> { { RegexCache.Get(DateTimeDefinitions.TimeRegexes1, RegexFlags), TimeType.CjkTime }, { RegexCache.Get(DateTimeDefinitions.TimeRegexes2, RegexFlags), TimeType.DigitTime }, { RegexCache.Get(DateTimeDefinitions.TimeRegexes3, RegexFlags), TimeType.LessTime }, }; Regexes = regexes.ToImmutableDictionary(); }
public ChineseTimePeriodExtractorChsConfiguration() { var regexes = new Dictionary <Regex, PeriodType> { { RegexCache.Get(DateTimeDefinitions.TimePeriodRegexes1, RegexFlags), PeriodType.FullTime }, { RegexCache.Get(DateTimeDefinitions.TimePeriodRegexes2, RegexFlags), PeriodType.ShortTime }, { RegexCache.Get(DateTimeDefinitions.TimeOfDayRegex, RegexFlags), PeriodType.ShortTime }, }; Regexes = regexes.ToImmutableDictionary(); }
public EnglishNumberParserConfiguration(INumberOptionsConfiguration config) { this.Config = config; this.LanguageMarker = NumbersDefinitions.LangMarker; // @TODO Temporary workaround var culture = config.Culture; if (culture.IndexOf("*", StringComparison.Ordinal) != -1) { culture = config.Culture.Replace("*", "us"); } this.CultureInfo = new CultureInfo(culture); this.IsCompoundNumberLanguage = NumbersDefinitions.CompoundNumberLanguage; this.IsMultiDecimalSeparatorCulture = NumbersDefinitions.MultiDecimalSeparatorCulture; this.DecimalSeparatorChar = NumbersDefinitions.DecimalSeparatorChar; this.FractionMarkerToken = NumbersDefinitions.FractionMarkerToken; this.NonDecimalSeparatorChar = NumbersDefinitions.NonDecimalSeparatorChar; this.HalfADozenText = NumbersDefinitions.HalfADozenText; this.WordSeparatorToken = NumbersDefinitions.WordSeparatorToken; this.WrittenDecimalSeparatorTexts = NumbersDefinitions.WrittenDecimalSeparatorTexts; this.WrittenGroupSeparatorTexts = NumbersDefinitions.WrittenGroupSeparatorTexts; this.WrittenIntegerSeparatorTexts = NumbersDefinitions.WrittenIntegerSeparatorTexts; this.WrittenFractionSeparatorTexts = NumbersDefinitions.WrittenFractionSeparatorTexts; this.CardinalNumberMap = NumbersDefinitions.CardinalNumberMap.ToImmutableDictionary(); this.OrdinalNumberMap = NumbersDefinitions.OrdinalNumberMap.ToImmutableDictionary(); this.RelativeReferenceOffsetMap = NumbersDefinitions.RelativeReferenceOffsetMap.ToImmutableDictionary(); this.RelativeReferenceRelativeToMap = NumbersDefinitions.RelativeReferenceRelativeToMap.ToImmutableDictionary(); this.RoundNumberMap = NumbersDefinitions.RoundNumberMap.ToImmutableDictionary(); this.HalfADozenRegex = RegexCache.Get(NumbersDefinitions.HalfADozenRegex, RegexFlags); this.DigitalNumberRegex = RegexCache.Get(NumbersDefinitions.DigitalNumberRegex, RegexFlags); this.NegativeNumberSignRegex = RegexCache.Get(NumbersDefinitions.NegativeNumberSignRegex, RegexFlags); this.FractionPrepositionRegex = RegexCache.Get(NumbersDefinitions.FractionPrepositionRegex, RegexFlags); this.RoundMultiplierRegex = RegexCache.Get(NumbersDefinitions.RoundMultiplierRegex, RegexFlags); }
/// <summary> /// Получить идентификатор ютубы. /// </summary> /// <param name="uri">URI.</param> /// <returns>Идентификатор.</returns> public string GetYoutubeIdFromUri(string uri) { try { if (uri == null) { return(null); } var youtubeRegex = RegexCache.CreateRegex(YoutubeRegex); var match = youtubeRegex.Match(uri); if (match.Success) { return(match.Groups[1].Value); } return(null); } catch { return(null); } }
protected HashSet <Regex> BuildRegexFromSet(IEnumerable <string> collection, bool ignoreCase = true) { var regexes = new HashSet <Regex>(); foreach (var regexString in collection) { var regexTokens = new List <string>(); foreach (var token in regexString.Split('|')) { regexTokens.Add(Regex.Escape(token)); } var pattern = $@"{this.config.BuildPrefix}({string.Join("|", regexTokens)}){this.config.BuildSuffix}"; var options = RegexOptions.Singleline | RegexOptions.ExplicitCapture | (ignoreCase ? RegexOptions.IgnoreCase : RegexOptions.None); var regex = RegexCache.Get(pattern, options); regexes.Add(regex); } return(regexes); }
/// <summary> /// read the rules. /// </summary> /// <param name="regexStrings">rule list.</param> /// <param name="ignoreCase">.</param> /// <returns>Immutable HashSet of regex.</returns> protected static ImmutableHashSet <Regex> BuildRegexes(HashSet <string> regexStrings, bool ignoreCase = false) { var regexes = new HashSet <Regex>(); foreach (var regexString in regexStrings) { // var sl = "(?=\\b)(" + regexStr + ")(?=(s?\\b))"; var regexOptions = RegexOptions.Singleline | RegexOptions.ExplicitCapture; if (ignoreCase) { regexOptions |= RegexOptions.IgnoreCase; } Regex regex = RegexCache.Get(regexString, regexOptions); regexes.Add(regex); } return(regexes.ToImmutableHashSet()); }
public PercentageExtractor() { var regexes = new Dictionary <Regex, TypeTag>() { { // 백퍼센트 십오퍼센트 RegexCache.Get(NumbersDefinitions.SimplePercentageRegex, RegexFlags), RegexTagGenerator.GenerateRegexTag(Constants.PERCENT_PREFIX, Constants.KOREAN) }, { // 19퍼센트 1퍼센트 RegexCache.Get(NumbersDefinitions.NumbersPercentagePointRegex, RegexFlags), RegexTagGenerator.GenerateRegexTag(Constants.PERCENT_PREFIX, Constants.NUMBER_SUFFIX) }, { // 3,000퍼센트 1,123퍼센트 RegexCache.Get(NumbersDefinitions.NumbersPercentageWithSeparatorRegex, RegexFlags), RegexTagGenerator.GenerateRegexTag(Constants.PERCENT_PREFIX, Constants.NUMBER_SUFFIX) }, { // 3.2 k 퍼센트 RegexCache.Get(NumbersDefinitions.NumbersPercentageWithMultiplierRegex, RegexFlags), RegexTagGenerator.GenerateRegexTag(Constants.PERCENT_PREFIX, Constants.NUMBER_SUFFIX) }, { // 15k퍼센트 RegexCache.Get(NumbersDefinitions.SimpleNumbersPercentageWithMultiplierRegex, RegexFlags), RegexTagGenerator.GenerateRegexTag(Constants.PERCENT_PREFIX, Constants.NUMBER_SUFFIX) }, { // 마이너스십삼퍼센트 RegexCache.Get(NumbersDefinitions.SimpleIntegerPercentageRegex, RegexFlags), RegexTagGenerator.GenerateRegexTag(Constants.PERCENT_PREFIX, Constants.NUMBER_SUFFIX) }, }; Regexes = regexes.ToImmutableDictionary(); }
public DoubleAveExceptionTests() { var mediator = new Mock <IMediator>(); mediator.Setup(x => x.Send(It.IsAny <AddressSystemFromPlace.Command>(), It.IsAny <CancellationToken>())) .Returns((AddressSystemFromPlace.Command g, CancellationToken t) => { if (g?.CityKey == "slc") { return(Task.FromResult(new[] { new PlaceGridLink("slc", "salt lake city", 1) } as IReadOnlyCollection <GridLinkable>)); } return(Task.FromResult(Array.Empty <GridLinkable>() as IReadOnlyCollection <GridLinkable>)); }); mediator.Setup(x => x.Send(It.IsAny <AddressSystemFromZipCode.Command>(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult(Array.Empty <GridLinkable>() as IReadOnlyCollection <GridLinkable>)); var regex = new RegexCache(new Abbreviations()); _handler = new DoubleAvenuesException.DoubleAvenueExceptionPipeline <ZoneParsing.Command, GeocodeAddress>(regex, new Mock <ILogger>().Object); _requestHandler = new ZoneParsing.Handler(regex, mediator.Object, new Mock <ILogger>().Object); }
public FractionExtractor(BaseNumberOptionsConfiguration config) { var regexes = new Dictionary <Regex, TypeTag> { { // -4 5/2, 4 6/3 RegexCache.Get(NumbersDefinitions.FractionNotationSpecialsCharsRegex, RegexFlags), RegexTagGenerator.GenerateRegexTag(Constants.FRACTION_PREFIX, Constants.NUMBER_SUFFIX) }, { // 8/3 RegexCache.Get(NumbersDefinitions.FractionNotationRegex, RegexFlags), RegexTagGenerator.GenerateRegexTag(Constants.FRACTION_PREFIX, Constants.NUMBER_SUFFIX) }, { // 四分之六十五 RegexCache.Get(NumbersDefinitions.AllFractionNumber, RegexFlags), RegexTagGenerator.GenerateRegexTag(Constants.FRACTION_PREFIX, Constants.CHINESE) }, }; Regexes = regexes.ToImmutableDictionary(); }
public FractionExtractor() { var regexes = new Dictionary <Regex, TypeTag> { { // -4 5/2, 4 6/3 RegexCache.Get(NumbersDefinitions.FractionNotationSpecialsCharsRegex, RegexFlags), RegexTagGenerator.GenerateRegexTag(Constants.FRACTION_PREFIX, Constants.NUMBER_SUFFIX) }, { // 8/3 RegexCache.Get(NumbersDefinitions.FractionNotationRegex, RegexFlags), RegexTagGenerator.GenerateRegexTag(Constants.FRACTION_PREFIX, Constants.NUMBER_SUFFIX) }, { // 오분의 이 칠분의 삼 RegexCache.Get(NumbersDefinitions.AllFractionNumber, RegexFlags), RegexTagGenerator.GenerateRegexTag(Constants.FRACTION_PREFIX, Constants.KOREAN) }, }; Regexes = regexes.ToImmutableDictionary(); }
private OrdinalExtractor(NumberOptions options) : base(options) { AmbiguousFractionConnectorsRegex = RegexCache.Get(NumbersDefinitions.AmbiguousFractionConnectorsRegex, RegexFlags); RelativeReferenceRegex = RegexCache.Get(NumbersDefinitions.RelativeOrdinalRegex, RegexFlags); var regexes = new Dictionary <Regex, TypeTag> { { RegexCache.Get(NumbersDefinitions.RelativeOrdinalRegex, RegexFlags), RegexTagGenerator.GenerateRegexTag(Constants.ORDINAL_PREFIX, Constants.HINDI) }, { RegexCache.Get(NumbersDefinitions.HinglishOrdinalRegex, RegexFlags), RegexTagGenerator.GenerateRegexTag(Constants.ORDINAL_PREFIX, Constants.HINDI) }, { RegexCache.Get(NumbersDefinitions.CompoundHindiOrdinalRegex, RegexFlags), RegexTagGenerator.GenerateRegexTag(Constants.ORDINAL_PREFIX, Constants.HINDI) }, { RegexCache.Get(NumbersDefinitions.CompoundNumberOrdinals, RegexFlags), RegexTagGenerator.GenerateRegexTag(Constants.ORDINAL_PREFIX, Constants.HINDI) }, { RegexCache.Get(NumbersDefinitions.CompoundEnglishOrdinalRegex, RegexFlags), RegexTagGenerator.GenerateRegexTag(Constants.ORDINAL_PREFIX, Constants.HINDI) }, { RegexCache.Get(NumbersDefinitions.OrdinalSuffixRegex, RegexFlags), RegexTagGenerator.GenerateRegexTag(Constants.ORDINAL_PREFIX, Constants.NUMBER_SUFFIX) }, }; Regexes = regexes.ToImmutableDictionary(); }
public ParsedContent Parse(string content) { var regEx = RegexCache.Get(string.Join("|", _registeredTokens.Select(t => "(?<" + t.Name + ">" + t.Pattern + ")").ToArray())); var matches = regEx.Matches(content); List <ParsedToken> tokens = new List <ParsedToken>(); foreach (Match match in matches) { foreach (var t in _registeredTokens) { if (match.Groups[t.Name] != null) { var m = match.Groups[t.Name]; if (m.Success) { ParsedToken p = t.Parse(m.Index, m.Length, m.Value); tokens.Add(p); } } } } return(new ParsedContent(content, tokens)); }
private OrdinalExtractor() { var regexes = new Dictionary <Regex, TypeTag> { { RegexCache.Get(NumbersDefinitions.OrdinalSuffixRegex, RegexFlags), RegexTagGenerator.GenerateRegexTag(Constants.ORDINAL_PREFIX, Constants.NUMBER_SUFFIX) }, { RegexCache.Get(NumbersDefinitions.OrdinalNumericRegex, RegexFlags), RegexTagGenerator.GenerateRegexTag(Constants.ORDINAL_PREFIX, Constants.NUMBER_SUFFIX) }, { RegexCache.Get(NumbersDefinitions.OrdinalGermanRegex, RegexFlags), RegexTagGenerator.GenerateRegexTag(Constants.ORDINAL_PREFIX, Constants.GERMAN) }, { RegexCache.Get(NumbersDefinitions.OrdinalRoundNumberRegex, RegexFlags), RegexTagGenerator.GenerateRegexTag(Constants.ORDINAL_PREFIX, Constants.GERMAN) }, }; Regexes = regexes.ToImmutableDictionary(); }
public ArabicNumberRangeParserConfiguration(INumberOptionsConfiguration config) { if (config.Culture == "ar-*") { CultureInfo = new CultureInfo("ar"); } else { CultureInfo = new CultureInfo(config.Culture); } var numConfig = new BaseNumberOptionsConfiguration(config.Culture, config.Options); NumberExtractor = Arabic.NumberExtractor.GetInstance(numConfig); OrdinalExtractor = Arabic.OrdinalExtractor.GetInstance(numConfig); NumberParser = new BaseNumberParser(new ArabicNumberParserConfiguration(config)); MoreOrEqual = RegexCache.Get(NumbersDefinitions.MoreOrEqual, RegexFlags); LessOrEqual = RegexCache.Get(NumbersDefinitions.LessOrEqual, RegexFlags); MoreOrEqualSuffix = RegexCache.Get(NumbersDefinitions.MoreOrEqualSuffix, RegexFlags); LessOrEqualSuffix = RegexCache.Get(NumbersDefinitions.LessOrEqualSuffix, RegexFlags); MoreOrEqualSeparate = RegexCache.Get(NumbersDefinitions.OneNumberRangeMoreSeparateRegex, RegexFlags); LessOrEqualSeparate = RegexCache.Get(NumbersDefinitions.OneNumberRangeLessSeparateRegex, RegexFlags); }
public void testRegexInsertion() { var regexCache = new RegexCache(2); String regex1 = "[1-5]"; String regex2 = "(?:12|34)"; String regex3 = "[1-3][58]"; regexCache.getRegexForRegex(regex1); Assert.IsTrue(regexCache.ContainsRegex(regex1)); regexCache.getRegexForRegex(regex2); Assert.IsTrue(regexCache.ContainsRegex(regex2)); Assert.IsTrue(regexCache.ContainsRegex(regex1)); regexCache.getRegexForRegex(regex1); Assert.IsTrue(regexCache.ContainsRegex(regex1)); regexCache.getRegexForRegex(regex3); Assert.IsTrue(regexCache.ContainsRegex(regex3)); Assert.IsFalse(regexCache.ContainsRegex(regex2)); Assert.IsTrue(regexCache.ContainsRegex(regex1)); }
public static string[] Split(string input, [StringSyntax(StringSyntaxAttribute.Regex, nameof(options))] string pattern, RegexOptions options, TimeSpan matchTimeout) => RegexCache.GetOrAdd(pattern, options, matchTimeout).Split(input);
/// <summary> /// Searches the input string for one or more occurrences of the text /// supplied in the pattern parameter with matching options supplied in the options /// parameter. /// </summary> public static bool IsMatch(string input, [StringSyntax(StringSyntaxAttribute.Regex, "options")] string pattern, RegexOptions options) => RegexCache.GetOrAdd(pattern, options, s_defaultMatchTimeout).IsMatch(input);
public ChineseIpExtractorConfiguration(SequenceOptions options) : base(options) { Ipv4Regex = RegexCache.Get(IpDefinitions.Ipv4Regex, RegexOptions.Compiled); Ipv6Regex = RegexCache.Get(IpDefinitions.Ipv6Regex, RegexOptions.Compiled); }
/// <summary> /// Splits the <paramref name="input "/>string at the position defined /// by <paramref name="pattern"/>. /// </summary> public static string[] Split(string input, [StringSyntax(StringSyntaxAttribute.Regex)] string pattern) => RegexCache.GetOrAdd(pattern).Split(input);
/// <summary> /// Replaces all occurrences of the <paramref name="pattern"/> with the recent /// replacement pattern. /// </summary> public static string Replace(string input, string pattern, MatchEvaluator evaluator) => RegexCache.GetOrAdd(pattern).Replace(input, evaluator);
public static string Replace(string input, string pattern, MatchEvaluator evaluator, RegexOptions options, TimeSpan matchTimeout) => RegexCache.GetOrAdd(pattern, options, matchTimeout).Replace(input, evaluator);
/// <summary> /// Replaces all occurrences of the pattern with the <paramref name="replacement"/> pattern, starting at /// the first character in the input string. /// </summary> public static string Replace(string input, string pattern, string replacement) => RegexCache.GetOrAdd(pattern).Replace(input, replacement);
public RegexCacheTest() { regexCache = new RegexCache(2); }
public NumberRangeExtractor(INumberOptionsConfiguration config) : base( NumberExtractor.GetInstance(), OrdinalExtractor.GetInstance(), new BaseNumberParser(new TurkishNumberParserConfiguration(config)), config) { var regexes = new Dictionary <Regex, string>() { { // between...and... RegexCache.Get(NumbersDefinitions.TwoNumberRangeRegex1, RegexFlags), NumberRangeConstants.TWONUMBETWEEN }, { // more than ... less than ... RegexCache.Get(NumbersDefinitions.TwoNumberRangeRegex2, RegexFlags), NumberRangeConstants.TWONUM }, { // less than ... more than ... RegexCache.Get(NumbersDefinitions.TwoNumberRangeRegex3, RegexFlags), NumberRangeConstants.TWONUM }, { // from ... to/~/- ... RegexCache.Get(NumbersDefinitions.TwoNumberRangeRegex4, RegexFlags), NumberRangeConstants.TWONUMTILL }, { // more/greater/higher than ... RegexCache.Get(NumbersDefinitions.OneNumberRangeMoreRegex1, RegexFlags), NumberRangeConstants.MORE }, { // 30 and/or greater/higher RegexCache.Get(NumbersDefinitions.OneNumberRangeMoreRegex2, RegexFlags), NumberRangeConstants.MORE }, { // less/smaller/lower than ... RegexCache.Get(NumbersDefinitions.OneNumberRangeLessRegex1, RegexFlags), NumberRangeConstants.LESS }, { // 30 and/or less/smaller/lower RegexCache.Get(NumbersDefinitions.OneNumberRangeLessRegex2, RegexFlags), NumberRangeConstants.LESS }, { // equal to ... RegexCache.Get(NumbersDefinitions.OneNumberRangeEqualRegex, RegexFlags), NumberRangeConstants.EQUAL }, { // equal to 30 or more than, larger than 30 or equal to ... RegexCache.Get(NumbersDefinitions.OneNumberRangeMoreSeparateRegex, RegexFlags), NumberRangeConstants.MORE }, { // equal to 30 or less, smaller than 30 or equal ... RegexCache.Get(NumbersDefinitions.OneNumberRangeLessSeparateRegex, RegexFlags), NumberRangeConstants.LESS }, }; Regexes = regexes.ToImmutableDictionary(); }
public TurkishDateExtractorConfiguration(IDateTimeOptionsConfiguration config) : base(config) { var numOptions = NumberOptions.None; if ((config.Options & DateTimeOptions.NoProtoCache) != 0) { numOptions = NumberOptions.NoProtoCache; } var numConfig = new BaseNumberOptionsConfiguration(config.Culture, numOptions); IntegerExtractor = Number.Turkish.IntegerExtractor.GetInstance(); OrdinalExtractor = Number.Turkish.OrdinalExtractor.GetInstance(); NumberParser = new BaseNumberParser(new TurkishNumberParserConfiguration(new BaseNumberOptionsConfiguration(numConfig))); DurationExtractor = new BaseDurationExtractor(new TurkishDurationExtractorConfiguration(this)); HolidayExtractor = new BaseHolidayExtractor(new TurkishHolidayExtractorConfiguration(this)); UtilityConfiguration = new TurkishDatetimeUtilityConfiguration(); ImplicitDateList = new List <Regex> { // extract "12" from "on 12" OnRegex, // extract "12th" from "on/at/in 12th" RelaxedOnRegex, // "the day before yesterday", "previous day", "today", "yesterday", "tomorrow" SpecialDayRegex, // "this Monday", "Tuesday of this week" ThisRegex, // "last/previous Monday", "Monday of last week" LastDateRegex, // "next/following Monday", "Monday of next week" NextDateRegex, // "Sunday", "Weds" SingleWeekDayRegex, // "2nd Monday of April" WeekDayOfMonthRegex, // "on the 12th" SpecialDate, // "two days from today", "five days from tomorrow" SpecialDayWithNumRegex, // "three Monday from now" RelativeWeekDayRegex, }; if ((Options & DateTimeOptions.CalendarMode) != 0) { ImplicitDateList = ImplicitDateList.Concat(new[] { DayRegex }); } // Gelecek Pazar (1 Nisan 2016) var dateRegex4 = RegexCache.Get(DateTimeDefinitions.DateExtractor4, RegexFlags); // 23-3-2015 (,Pazar|(Pazar))? var dateRegex5 = RegexCache.Get(DateTimeDefinitions.DateExtractor5, RegexFlags); // Gelecek Pazar (1-1-2016) var dateRegex6 = RegexCache.Get(DateTimeDefinitions.DateExtractor6, RegexFlags); // 6 Nisan'da or Altı Nisan'da var dateRegex7 = RegexCache.Get(DateTimeDefinitions.DateExtractor7, RegexFlags); // 2015 yılı Nisan'ın 6'sı(nda)? (Pazar)? var dateRegex8 = RegexCache.Get(DateTimeDefinitions.DateExtractor8, RegexFlags); // 6'ncı Çarşamba or Altıncı Çarşamba var dateRegex9 = RegexCache.Get(DateTimeDefinitions.DateExtractor9, RegexFlags); // "(Sunday,)? 7/23, 2018", year part is required var dateRegex7L = RegexCache.Get(DateTimeDefinitions.DateExtractor7L, RegexFlags); // "(Sunday,)? 7/23", year part is not required var dateRegex7S = RegexCache.Get(DateTimeDefinitions.DateExtractor7S, RegexFlags); // "(Sunday,)? 23/7, 2018", year part is required var dateRegex9L = RegexCache.Get(DateTimeDefinitions.DateExtractor9L, RegexFlags); // "(Sunday,)? 23/7", year part is not required var dateRegex9S = RegexCache.Get(DateTimeDefinitions.DateExtractor9S, RegexFlags); // (Sunday,)? 2015-12-23 var dateRegexA = RegexCache.Get(DateTimeDefinitions.DateExtractorA, RegexFlags); DateRegexList = new List <Regex> { // 5 Nisan (Pazar|(Pazar)|,Pazar)? or 5 Nisan 2016 (Pazar|(Pazar)|,Pazar)? RegexCache.Get(DateTimeDefinitions.DateExtractor1, RegexFlags), // Gelecek ayın 6'sı(nda)? (Pazar)? or Gelecek ayın altısı(nda)? (Pazar)? RegexCache.Get(DateTimeDefinitions.DateExtractor3, RegexFlags), }; var enableDmy = DmyDateFormat || DateTimeDefinitions.DefaultLanguageFallback == Constants.DefaultLanguageFallback_DMY; DateRegexList = DateRegexList.Concat(enableDmy ? new[] { dateRegex5, dateRegex8, dateRegex9L, dateRegex9S, dateRegex4, dateRegex6, dateRegex7L, dateRegex7S, dateRegexA } : new[] { dateRegex4, dateRegex6, dateRegex7L, dateRegex7S, dateRegex5, dateRegex8, dateRegex9L, dateRegex9S, dateRegexA }); }
public static string Replace(string input, [StringSyntax(StringSyntaxAttribute.Regex, nameof(options))] string pattern, MatchEvaluator evaluator, RegexOptions options, TimeSpan matchTimeout) => RegexCache.GetOrAdd(pattern, options, matchTimeout).Replace(input, evaluator);
/// <summary> /// Replaces all occurrences of the <paramref name="pattern"/> with the recent /// replacement pattern. /// </summary> public static string Replace(string input, [StringSyntax(StringSyntaxAttribute.Regex)] string pattern, MatchEvaluator evaluator) => RegexCache.GetOrAdd(pattern).Replace(input, evaluator);
public void SetupFixture() { regexCache = new RegexCache(2); }
/// <summary> /// Searches the input string for one or more occurrences of the text /// supplied in the pattern parameter. /// </summary> public static Match Match(string input, [StringSyntax(StringSyntaxAttribute.Regex)] string pattern) => RegexCache.GetOrAdd(pattern).Match(input);
public static string Replace(string input, string pattern, string replacement, RegexOptions options, TimeSpan matchTimeout) => RegexCache.GetOrAdd(pattern, options, matchTimeout).Replace(input, replacement);
public static Match Match(string input, [StringSyntax(StringSyntaxAttribute.Regex, "options")] string pattern, RegexOptions options, TimeSpan matchTimeout) => RegexCache.GetOrAdd(pattern, options, matchTimeout).Match(input);
public static void SetupFixture(TestContext context) { regexCache = new RegexCache(2); }