gpt4 book ai didi

javascript - 为字符串创建动态段落

转载 作者:行者123 更新时间:2023-12-02 17:44:33 25 4
gpt4 key购买 nike

创建动态 <p> 时遇到以下问题使用响应的元素!响应是纯文本。我需要确定字符串是否包含换行符或段落分隔符。

示例字符串

All rates are inclusive of the applicable Service charge, VAT, NBT & TDL currently at the prevailing 10%, 12%, 2% & 1% respectively. In the event of a change in the Service charge, VAT, NBT & TDL or the introduction of additional taxes, the Contract Rates will be adjusted accordingly.

All rates are inclusive of the applicable Service charge, VAT, NBT & TDL currently at the prevailing 10%, 12%, 2% & 1% respectively. In the event of a change in the Service charge, VAT, NBT & TDL or the introduction of additional taxes, the Contract Rates will be adjusted accordingly.

All rates are inclusive of the applicable Service charge, VAT, NBT & TDL currently at the prevailing 10%, 12%, 2% & 1% respectively. In the event of a change in the Service charge, VAT, NBT & TDL or the introduction of additional taxes, the Contract Rates will be adjusted accordingly.

这个字符串是三段组合在一起的!我如何识别每个单独的段落以创建单独的 <p>使用 JavaScript 为每个段落添加标签。

最佳答案

你真的应该发布一些代码,但是试试这个

var paragraphed = "<p>" + originalString.split("\n").join("</p><p>") + "</p>";

关于javascript - 为字符串创建动态段落,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21877304/

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