private Match ValidateCustomPattern(string custPattern)
        {
            try
            {
                Match m = null;
                lock (fullPatternCache)
                {
                    if (fullPatternCache.TryGetValue(custPattern, out m))
                    {
                        return(m);
                    }

                    m = MyRegex.Match(custPattern);
                    if (!m.Success)
                    {
                        throw new FormatException();
                    }
                    fullPatternCache.Add(custPattern, m);
                }
                return(m);
            }
            catch
            {
                throw new FormatException();
            }
        }
示例#2
0
 private static string[] VariablesFromString(string markup)
 {
     return(markup.Split(',').Select(var =>
     {
         Match match = MyRegex.Match(var, string.Format(R.Q(@"\s*({0})\s*"), Liquid.QuotedFragment));
         return (match.Success && !string.IsNullOrEmpty(match.Groups[1].Value))
                                 ? match.Groups[1].Value
                                 : null;
     }).ToArray());
 }
示例#3
0
        public static string FromShortHand(string @string)
        {
            if (@string == null)
            {
                return(@string);
            }

            Match match = MyRegex.Match(@string, Liquid.CommentShorthand);

            return(match.Success ? string.Format(@"{{% comment %}}{0}{{% endcomment %}}", match.Groups[1].Value) : @string);
        }