如何将带有 HTML 标签的文本拆分为数组

Jak*_*mpl 5 c# windows-8.1 windows-phone-8.1 win-universal-app

我有非常简单的 HTML 文本(只有<b>标签),例如

Lorem Ipsum is <b>simply dummy</b> text of the printing and <b>typesetting industry</b>

我想将文本拆分为这样的数组:

[0] - Lorem Ipsum is 
[1] - <b>simply dummy</b>
[2] - text of the printing and
[3] - <b>typesetting industry</b>
Run Code Online (Sandbox Code Playgroud)

HTML 标签内的文本必须与另一个文本分开。有什么简单的解决方案吗?

谢谢

Had*_*iRj 5

您可以使用以下代码实现此目的

string value = @"Lorem Ipsum is <b>simply dummy</b> text of the printing and <b>typesetting industry</b>";
var parts = Regex.Split(value, @"(<b>[\s\S]+?<\/b>)").Where(l => l != string.Empty).ToArray();
Run Code Online (Sandbox Code Playgroud)