gpt4 book ai didi

javascript - 使用 Javascript RegEx 在插入换行符之前查找最后一个空格,除了一些标点符号

转载 作者:行者123 更新时间:2023-11-29 18:05:54 25 4
gpt4 key购买 nike

<分区>

这是我的声明:

text.replace(/(.{35})/g, "$1\n");

有效,它每 35 个字符插入一个新行。但是,我不想一个字被删减一半。我如何找到第 35 个字符之前的最后一个空格?是否可以使用 RegEx?它执行的 block 最多应插入 6 个换行符,因为总字符数限制为 210 个字符。

这是当前输出:

This is an example of current output:
this is some text that has been for
matted by that statement.

这就是我想要的:

This is an example of current output:
this is some text that has been
formatted by that statement.

它正在文本字段上执行。

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