コード例 #1
0
 public void ReplaceAll(Regex find, string replace)
 {
     Execute(() =>
     {
         try
         {
             var offset = 0;
             EditBox.BeginChange();
             foreach (Match match in find.Matches(EditBox.Text))
             {
                 var replaceWith = match.Result(replace);
                 EditBox.Document.Replace(offset + match.Index, match.Length, replaceWith);
                 offset += replaceWith.Length - match.Length;
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.ToString());
         }
         finally
         {
             EditBox.EndChange();
         }
     });
 }