Exemplo n.º 1
0
    /// <summary>
    /// The replace.
    /// </summary>
    /// <param name="text">
    /// The text.
    /// </param>
    /// <param name="replacement">
    /// The replacement.
    /// </param>
    public override void Replace(ref string text, IReplaceBlocks replacement)
    {
      Match m = this._regExSearch.Match(text);
      while (m.Success)
      {
        string replaceItem = this._regExReplace.Replace("${inner}", this.GetInnerValue(m.Groups["inner"].Value));

        int replaceIndex = replacement.Add(replaceItem);
        text = text.Substring(0, m.Groups[0].Index) + replacement.Get(replaceIndex) +
               text.Substring(m.Groups[0].Index + m.Groups[0].Length);

        m = this._regExSearch.Match(text);
      }
    }
Exemplo n.º 2
0
        /// <summary>
        /// The replace.
        /// </summary>
        /// <param name="text">
        /// The text.
        /// </param>
        /// <param name="replacement">
        /// The replacement.
        /// </param>
        public override void Replace(ref string text, IReplaceBlocks replacement)
        {
            Match m = this._regExSearch.Match(text);

            while (m.Success)
            {
                string replaceItem = this._regExReplace.Replace("${inner}", this.GetInnerValue(m.Groups["inner"].Value));

                int replaceIndex = replacement.Add(replaceItem);
                text = text.Substring(0, m.Groups[0].Index) + replacement.Get(replaceIndex) +
                       text.Substring(m.Groups[0].Index + m.Groups[0].Length);

                m = this._regExSearch.Match(text);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// The replace.
        /// </summary>
        /// <param name="text">
        /// The text.
        /// </param>
        /// <param name="replacement">
        /// The replacement.
        /// </param>
        public override void Replace(ref string text, IReplaceBlocks replacement)
        {
            var m = this.RegExSearch.Match(text);

            while (m.Success)
            {
                var replaceItem = this.RegExReplace.Replace("${inner}", this.GetInnerValue(m.Groups["inner"].Value));

                var replaceIndex = replacement.Add(replaceItem);
                text =
                    $"{text.Substring(0, m.Groups[0].Index)}{replacement.Get(replaceIndex)}{text.Substring(m.Groups[0].Index + m.Groups[0].Length)}";

                m = this.RegExSearch.Match(text);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// The replace.
        /// </summary>
        /// <param name="text">
        /// The text.
        /// </param>
        /// <param name="replacement">
        /// The replacement.
        /// </param>
        public override void Replace(ref string text, IReplaceBlocks replacement)
        {
            int index = -1;

            do
            {
                index = text.FastIndexOf(this._find);

                if (index >= 0)
                {
                    // replace it...
                    int replaceIndex = replacement.Add(this._replace);
                    text = text.Substring(0, index) + replacement.Get(replaceIndex) +
                           text.Substring(index + this._find.Length);
                }
            }while (index >= 0);
        }
        /// <summary>
        /// The replace.
        /// </summary>
        /// <param name="text">
        /// The text.
        /// </param>
        /// <param name="replacement">
        /// The replacement.
        /// </param>
        public override void Replace(ref string text, IReplaceBlocks replacement)
        {
            Match m = this._regExSearch.Match(text);
            while (m.Success)
            {
                string inner = this._syntaxHighlighter.ColorText(
                    this.GetInnerValue(m.Groups["inner"].Value), m.Groups["language"].Value);

                string replaceItem = this._regExReplace.Replace("${inner}", inner);

                // pulls the htmls into the replacement collection before it's inserted back into the main text
                int replaceIndex = replacement.Add(replaceItem);

                text = text.Substring(0, m.Groups[0].Index) + replacement.Get(replaceIndex)
                       + text.Substring(m.Groups[0].Index + m.Groups[0].Length);

                m = this._regExSearch.Match(text);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// The replace.
        /// </summary>
        /// <param name="text">
        /// The text.
        /// </param>
        /// <param name="replacement">
        /// The replacement.
        /// </param>
        public override void Replace(ref string text, IReplaceBlocks replacement)
        {
            int index;

            do
            {
                index = text.FastIndexOf(this.find);

                if (index < 0)
                {
                    continue;
                }

                // replace it...
                var replaceIndex = replacement.Add(this.replace);
                text = text.Substring(0, index) + replacement.Get(replaceIndex) +
                       text.Substring(index + this.find.Length);
            }while (index >= 0);
        }
        /// <summary>
        /// The replace.
        /// </summary>
        /// <param name="text">
        /// The text.
        /// </param>
        /// <param name="replacement">
        /// The replacement.
        /// </param>
        public override void Replace(ref string text, IReplaceBlocks replacement)
        {
            Match m = this._regExSearch.Match(text);

            while (m.Success)
            {
                string inner = this._syntaxHighlighter.ColorText(
                    this.GetInnerValue(m.Groups["inner"].Value), m.Groups["language"].Value);

                string replaceItem = this._regExReplace.Replace("${inner}", inner);

                // pulls the htmls into the replacement collection before it's inserted back into the main text
                int replaceIndex = replacement.Add(replaceItem);

                text = text.Substring(0, m.Groups[0].Index) + replacement.Get(replaceIndex)
                       + text.Substring(m.Groups[0].Index + m.Groups[0].Length);

                m = this._regExSearch.Match(text);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// The replace.
        /// </summary>
        /// <param name="text">
        /// The text.
        /// </param>
        /// <param name="replacement">
        /// The replacement.
        /// </param>
        public override void Replace(ref string text, IReplaceBlocks replacement)
        {
            var m = this.RegExSearch.Match(text);

            while (m.Success)
            {
                var inner = this.syntaxHighlighter.ColorText(
                    this.GetInnerValue(m.Groups["inner"].Value), m.Groups["language"].Value, this.IsEditMode);

                var replaceItem = this.RegExReplace.Replace("${inner}", inner);

                // pulls the html's into the replacement collection before it's inserted back into the main text
                var replaceIndex = replacement.Add(replaceItem);

                text =
                    $"{text.Substring(0, m.Groups[0].Index)}{replacement.Get(replaceIndex)}{text.Substring(m.Groups[0].Index + m.Groups[0].Length)}";

                m = this.RegExSearch.Match(text);
            }
        }
        /// <summary>
        /// The get replacements from text.
        /// </summary>
        /// <param name="replaceBlocks">
        /// The replace Blocks.
        /// </param>
        /// <param name="sb">
        /// The sb.
        /// </param>
        public static void ReplaceHtmlFromText(this IReplaceBlocks replaceBlocks, ref StringBuilder sb)
        {
            Match m = _regExHtml.Match(sb.ToString());

            while (m.Success)
            {
                // add it to the list...
                int index = replaceBlocks.Add(m.Groups[0].Value);

                // replacement lookup code
                string replace = replaceBlocks.Get(index);

                // remove the replaced item...
                sb.Remove(m.Groups[0].Index, m.Groups[0].Length);

                // insert the replaced value back in...
                sb.Insert(m.Groups[0].Index, replace);

                // text = text.Substring( 0, m.Groups [0].Index ) + replace + text.Substring( m.Groups [0].Index + m.Groups [0].Length );
                m = _regExHtml.Match(sb.ToString());
            }
        }
        /// <summary>
        /// The replace.
        /// </summary>
        /// <param name="text">
        /// The text.
        /// </param>
        /// <param name="replacement">
        /// The replacement.
        /// </param>
        public override void Replace(ref string text, IReplaceBlocks replacement)
        {
            var sb = new StringBuilder(text);

              Match m = this._regExSearch.Match(text);
              while (m.Success)
              {
            // just replaces with no "inner"
            int replaceIndex = replacement.Add(this._regExReplace);

            // remove old bbcode...
            sb.Remove(m.Groups[0].Index, m.Groups[0].Length);

            // insert replaced value(s)
            sb.Insert(m.Groups[0].Index, replacement.Get(replaceIndex));

            // text = text.Substring( 0, m.Groups [0].Index ) + replacement.GetReplaceValue( replaceIndex ) + text.Substring( m.Groups [0].Index + m.Groups [0].Length );
            m = this._regExSearch.Match(sb.ToString());
              }

              text = sb.ToString();
        }
Exemplo n.º 11
0
        /// <summary>
        /// The replace.
        /// </summary>
        /// <param name="text">
        /// The text.
        /// </param>
        /// <param name="replacement">
        /// The replacement.
        /// </param>
        public override void Replace(ref string text, IReplaceBlocks replacement)
        {
            var sb = new StringBuilder(text);

            var m = this._regExSearch.Match(text);

            while (m.Success)
            {
                // just replaces with no "inner"
                var replaceIndex = replacement.Add(this._regExReplace);

                // remove old bbcode...
                sb.Remove(m.Groups[0].Index, m.Groups[0].Length);

                // insert replaced value(s)
                sb.Insert(m.Groups[0].Index, replacement.Get(replaceIndex));

                // text = text.Substring( 0, m.Groups [0].Index ) + replacement.GetReplaceValue( replaceIndex ) + text.Substring( m.Groups [0].Index + m.Groups [0].Length );
                m = this._regExSearch.Match(sb.ToString());
            }

            text = sb.ToString();
        }
Exemplo n.º 12
0
    /// <summary>
    /// The replace.
    /// </summary>
    /// <param name="text">
    /// The text.
    /// </param>
    /// <param name="replacement">
    /// The replacement.
    /// </param>
    public override void Replace(ref string text, IReplaceBlocks replacement)
    {
      int index = -1;

      do
      {
        
        index = text.FastIndexOf(this._find);

        if (index >= 0)
        {
          // replace it...
          int replaceIndex = replacement.Add(this._replace);
          text = text.Substring(0, index) + replacement.Get(replaceIndex) +
                 text.Substring(index + this._find.Length);
        }
      }
      while (index >= 0);
    }