ReplaceRegex
IPresentation.ReplaceRegex 方法
使用指定的字符串替换正则表达式的所有匹配项。
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 或更多的单词
presentation.ReplaceRegex(regex, "***", null);
presentation.Save("SomePresentation-out.pptx", SaveFormat.Pptx);
}
另见
- 接口 IFindResultCallback
- 接口 IPresentation
- 命名空间 Aspose.Slides
- 程序集 Aspose.Slides