|
@@ -350,8 +350,9 @@ public class WordStructuredExtractionService {
|
|
|
String result = text;
|
|
String result = text;
|
|
|
|
|
|
|
|
// 移除 TOC 域代码头(支持多种格式)
|
|
// 移除 TOC 域代码头(支持多种格式)
|
|
|
- // 格式: TOC \o "1-2" \h \z \u
|
|
|
|
|
- result = result.replaceAll("TOC\\s*(\\\\[ohzu]\\s*(\"[^\"]*\")?\\s*)+", "");
|
|
|
|
|
|
|
+ // 格式: TOC \o "1-2" \h \z \u (注意: Java 中 \u 是 Unicode 转义,需要特殊处理)
|
|
|
|
|
+ result = result.replaceAll("TOC\\s*(\\\\[ohzlwnt]\\s*(\"[^\"]*\")?\\s*)+", "");
|
|
|
|
|
+ result = result.replaceAll("TOC\\s*(\\\\u\\s*(\"[^\"]*\")?\\s*)+", "");
|
|
|
|
|
|
|
|
// 移除 HYPERLINK 域代码
|
|
// 移除 HYPERLINK 域代码
|
|
|
// 格式: HYPERLINK \l "_Toc176869144" 实际文本
|
|
// 格式: HYPERLINK \l "_Toc176869144" 实际文本
|
|
@@ -372,7 +373,9 @@ public class WordStructuredExtractionService {
|
|
|
result = result.replaceAll("PAGEREF\\s+\\S+\\s*(\\\\h)?\\s*\\d*", "");
|
|
result = result.replaceAll("PAGEREF\\s+\\S+\\s*(\\\\h)?\\s*\\d*", "");
|
|
|
|
|
|
|
|
// 移除其他常见域代码标记(如 \l \o \h \z \u)
|
|
// 移除其他常见域代码标记(如 \l \o \h \z \u)
|
|
|
- result = result.replaceAll("\\\\[lohzu]\\s*", "");
|
|
|
|
|
|
|
+ // 注意: Java 中 \u 是 Unicode 转义,需要分开处理
|
|
|
|
|
+ result = result.replaceAll("\\\\[lohzwnt]\\s*", "");
|
|
|
|
|
+ result = result.replaceAll("\\\\u\\s*", "");
|
|
|
|
|
|
|
|
// 清理多余空格
|
|
// 清理多余空格
|
|
|
result = result.replaceAll("\\s+", " ").trim();
|
|
result = result.replaceAll("\\s+", " ").trim();
|