简体   繁体   English

正则表达式以查找格式相似但长度可变的Word文档文本

[英]Regular Expression To Find Word Document Text of Similar Format, but Varying Length

Given a sample of some possible text containing the format 给定一些包含格式的可能文本的示例

$[I-VI].[1-99].[1-99].[1-99]…

I am trying to build a regular expression that will find all text formatted this way. 我正在尝试建立一个正则表达式,它将查找以这种方式格式化的所有文本。

So, some samples might be 因此,一些样本可能是

  • $II.4.13 $ II.4.13
  • $V.23.38.1.23 $ V.23.38.1.23
  • $IV.1.1.1.1.1 $ IV.1.1.1.1.1

As you can see, the length of the text is varying, but there are some known parameters. 如您所见,文本的长度是变化的,但是有一些已知的参数。 The most levels deep is 7, the $ always exists and there is always a . 最深的级别是7,$始终存在,并且始终有一个。 separating all roman numerals / numbers (except the last number). 分隔所有罗马数字/数字(最后一个数字除外)。

Any suggestions? 有什么建议么? Admittedly, I am currently weak in determining regular expressions. 诚然,我目前在确定正则表达式方面很虚弱。

I am using Word 2010 to try to find this text in a document, so Microsoft Office RegEx syntax would be preferred; 我正在使用Word 2010尝试在文档中查找此文本,因此将首选Microsoft Office RegEx语法。 but C# would be fine too as I could write a program to search the text and find this text as well. 但是C#也可以,因为我可以编写一个程序来搜索文本并找到该文本。

\\$(I|II|III|IV|V|VI)(\\.[0-9]{1,2})+

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM