本文介绍了用于在文档中查找特定文本的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在文档中有以下文本格式:

I have the below format of text in a document :

ECO [ECO-xxxxx]:封面

这里数字xxxxx发生变化,其余部分保持不变。另外,我需要排除格式为 的ECO [ECO-xxxxx]:封面(续)
当我是这个地区的新手时,拼命地寻求帮助。

非常感谢,

Tanya Sharma

ECO [ECO-xxxxx] : Cover Page

here the number xxxxx changes and the rest remains the same. Also I need to exclude the text which is in the format

ECO [ECO-xxxxx] : Cover Page (continued)

Desperately looking for some help as I am new to this area.

Thanks much,

Tanya Sharma

推荐答案


using System;
using System.Text.RegularExpressions;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            string textSource =
                "Introduction ...\n"+
                "ECO [ECO-00012] : Cover Page\n"+
                "Some text here ...\n"+
                "ECO [ECO-xxxxx] : Cover Page (continued)\n" +
                "Some more text  ...";

            MatchCollection ms = Regex.Matches(textSource, "^\\s*ECO \\[ECO-[0-9]*\\] : Cover Page\\s*



这篇关于用于在文档中查找特定文本的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-21 13:51