public string GetContentBetween(ParsedToken from, char beginChar, char endChar)
        {
            int start = from.Index + from.Length;
            int end   = FindScopeEnd(start, beginChar, endChar);

            return(_buffer.ToString(start, end - start));
        }
        public void ReplaceContentBetween(ParsedToken from, ParsedToken to, string newContent)
        {
            int start = from.Index + from.Length;
            int end   = (to.Index - start) + 1;

            RemoveContent(start, end);
            AppendContent(newContent, start);
        }
        public void ReplaceContentBetween(ParsedToken from, char beginChar, char endChar, string newContent)
        {
            int start = from.Index + from.Length;
            int end   = FindScopeEnd(start, beginChar, endChar) - start;

            RemoveContent(start, end);
            AppendContent(newContent, start);
        }
Exemple #4
0
        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));
        }
        public string GetContentBetween(ParsedToken from, ParsedToken to)
        {
            int start = from.Index + from.Length;

            return(_buffer.ToString(start, (to.Index - start) + 1));
        }
 public void RemoveToken(ParsedToken token)
 {
     _tokens.Remove(token);
     RemoveContent(token.Index, token.Length);
 }