gpt4 book ai didi

c# - 如何分割这个字符串并识别最后一个 '*' 之后的第一个句子?

转载 作者:行者123 更新时间:2023-12-01 23:54:57 44 4
gpt4 key购买 nike

我从数据库中获取了类似于以下内容的字符串:

The object of the following is to do:* blah 1 * blah 2 * blah 3 * blah 4. Some more extremely uninterestingtext. Followed by yet another sentencefull of extremely uninteresting text.Thankfully this is the last sentence.

I need to format this so that each * represents a bullet point, and the sentence after the last * goes onto a new line, ideally as follows:

The object of the following is to do: * blah 1* blah 2 * blah 3 * blah 4. Some more extremely uninterestingtext. Followed by yet another sentencefull of extremely uninteresting text.Thankfully this is the last sentence.

It's easy enough to split the string by the * character and replace that with <br /> *. I'm using the following for that:

string description = GetDescription();

description = description.Replace("*", "<br />*"); // it's going onto a web page.

但这给我的结果是:

The object of the following is to do: * blah 1 * blah 2 * blah 3 * blah 4. Some more extremely uninteresting text. Followed by yetanother sentence full of extremelyuninteresting text. Thankfully this isthe last sentence.

我在识别最后一个“*”之后的第一句话时遇到了一些困难,所以我也可以在那里休息一下。有人可以告诉我如何做到这一点吗?

最佳答案

您需要某种方法来确定最后一句中的其他分隔符。您可以对 * 进行全局替换至<br /> *就像您当前所做的那样,然后找到 * 的最后一个实例并替换下一个 .或任何带有 . <br /> 的分隔符。

更新

修正了 <br /> . 的顺序至. <br />正如@Shaded 指出的。

关于c# - 如何分割这个字符串并识别最后一个 '*' 之后的第一个句子?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3070627/

44 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com