vb.net - 有没有办法从 vb.net 中的 Word doc (2016) 中解析出下标和上标
问题描述
这听起来很简单,但我似乎无法找到一种方法来使用 vb.net 解析出 Word (2016) 中包含下标或上标的整个单词。我有一个 Word 文档,想用下标/上标解析所有单词,并将其保存在一个数组中以供下游的其他进程使用。请参阅下面的附加屏幕截图。
因此,如果代码从上到下读取,它会遇到的第一个具有下标/上标的单词是 R 1然后是 (CH 2 ) m CH 3,依此类推,将它们保存到一个数组中 - 想要获取整个包含下标/上标的单词 - [即:regex("\b(\w+)\b")]
尝试使用 if 语句检查下标/上标是否存在,但是一旦将其读入代码中,它就变成了常规字符,找不到匹配项,请参见下面的第二个屏幕截图。
有谁知道用下标/上标解析整个单词是否可行?提前致谢。
DEF_SUPERSCRIPT = "R¹X"
'loop through all of the paragraphs
For N = 1 To totalparagraphs
loopcount = loopcount + 1
newind = "No"
'read content of each line - but it came in as regular character 1 instead of superscript 1
content = Application.Selection.Paragraphs(N).Range.Text
'here is where - trying to determine if it could catch the line that has subscripts/superscrpits - but no match to be found
If (Application.Selection.Paragraphs(N).Range.Text.Contains(DEF_SUPERSCRIPT)) Then
MessageBox.Show("...found superscript here 1...", Msg_Title & SPACER2_MSGTITLE & "[" & Now() & "]", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
Next
解决方案
推荐阅读
- javascript - 数组以另一种方式包含字符串
- c++ - std::thread 和 tbb::task_group 之间的线程 ID 重用导致 OpenMP 中的死锁
- typescript - 如何使用 typescript 创建 react-native 自定义视图
- vue.js - Vue:拥有根组件与仅将组件放在 div 根中有什么区别?
- visualization - 在 MicroStrategy Reporting Tool (MSTR) 中,Numeric 提示、Big decimal 提示和 Long 提示有什么区别?
- jupyter-notebook - Jupyter-notebook ModuleNotFoundError:没有名为“游侠”的模块
- javascript - 可链接的函数变成了单例。如何预防
- python - 如何在 columnTransformer 中实现 SMOTE?
- node.js - 集成错误条带无效值值应该是客户端密码字符串。您指定:未定义
- python - 是什么让朴素贝叶斯成为垃圾邮件过滤/情感分析而不是决策树的更好分类器?