ReplaceRegex
TextFrame.ReplaceRegex method
用指定字符串替换正则表达式的所有匹配项。
public void ReplaceRegex(Regex regex, string newText, IFindResultCallback callback)
参数 | 类型 | 描述 |
---|---|---|
regex | Regex | 获取要被替换字符串的正则表达式 Regex。 |
newText | String | 用于替换所有被替换字符串的字符串。 |
callback | IFindResultCallback | 用于保存替换操作结果的回调对象 IFindResultCallback 。 |
示例
以下示例代码演示了如何使用正则表达式和指定字符串替换文本。
[C#]
using (Presentation presentation = new Presentation("SomePresentation.pptx")){
Regex regex = new Regex(@"\b[^\s]{10,}\b");
// 用 '***' 替换所有10个或更多字符的单词
((AutoShape)presentation.Slides[0].Shapes[0]).TextFrame.ReplaceRegex(regex, "***", null);
presentation.Save("SomePresentation-out.pptx", SaveFormat.Pptx);
}
另请参阅
- interface IFindResultCallback
- class TextFrame
- namespace Aspose.Slides
- assembly Aspose.Slides