0

我有以下代码:

<br>
                For Day October 21, 2013, The following locations have been restricted<br>
                <br>
                 No increases in nominations sourced from points west of Southeast for delivery to points east of Southeast, except for Primary Firm No-Notice nominations, will be accepted.<br>

我想匹配所有出现的<br><br>标签之间的文本,比如我需要输出为:

For Day October 21, 2013, The following locations have been restricted
No increases in nominations sourced from points west of Southeast for delivery to points east of Southeast, except for Primary Firm No-Notice nominations, will be accepted.

请为此建议我一个适当的正则表达式

4

2 回答 2

3

你确定你需要正则表达式吗?

尝试类似的东西

string output = sourceHtml.Replace("<br>", Environment.NewLine).Trim();

这将删除<br>标签并为您提供预期的结果。

于 2013-10-21T12:08:42.843 回答
0

尝试这个:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace RegexTester
{
    class Program
    {
        static void Main(string[] args)
        {
            var text = @"<br>
                For Day October 21, 2013, The following locations have been restricted<br>
                <br>
                 No increases in nominations sourced from points west of Southeast for delivery to points east of Southeast, except for Primary Firm No-Notice nominations, will be accepted.<br>";

            var pattern = "<br>\\s*";

            var result = Regex.Replace(text, pattern, string.Empty);

            Console.WriteLine(result);

            Console.ReadKey();
        }
    }
}
于 2013-10-21T12:29:46.620 回答