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 に答える