# 使用 Java 在 PPTX 演示文件中搜索文本

> Java 源代码，用于在 PPTX 演示文稿中搜索文本。

Source: https://products.aspose.com/slides/zh/java/search/pptx/
Updated: 2023-05-19



## 通过 Java 搜索和替换文本 PPTX 演示文稿

只需几行代码即可使用 Aspose.Slides for Java API 搜索和替换内容、评论、幻灯片注释或元数据中的文本。使用正则表达式匹配、匹配大小写来搜索演示文稿中的文本。在标题、内容、页脚或页眉中搜索文本。

### 使用 Java 搜索文本 PPTX 演示文稿

```java

Presentation presentation = new Presentation("welcome-to-powerpoint.pptx");
try {
    SlideUtil.findAndReplaceText(presentation, true, "PowerPoint", "Aspose.Slides", null);
    presentation.save("replaced.pptx", SaveFormat.Pptx);
} finally {
    if (presentation != null) presentation.dispose();
}
```

## 如何通过 Java 搜索 PPTX 的文本

这些是搜索文本 PPTX 文件的步骤。

使用 Presentation 实例加载 PPTX。

使用 [FindAndReplaceText](https://reference.aspose.com/slides/java/com.aspose.slides/slideutil/#findAndReplaceText-com.aspose.slides.IPresentation-boolean-java.lang.String-java.lang.String-) 方法查找和替换文本。

以 PPTX 格式保存结果

## 其他支持的搜索格式
