gpt4 book ai didi

javascript - 在javascript中将文本拆分为数组

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

我想在 javascript 文本中获取 . 时拆分。

我的文字是这样的:

The cats climbed the tall tree.In this sentence, $U_SEL{} is a noun.

我想要数组:

1.The cats climbed the tall tree.
2.In this sentence
3.$U_SEL{}
4.is a noun

最佳答案

试试这个

<script type="text/javascript">
var text = "The cats climbed the tall tree.In this sentence, $U_SEL{}, is a noun";
var spliteds = text.split(/[\.,]/);

alert(spliteds[0]);
alert(spliteds[1]);
alert(spliteds[2]);
alert(spliteds[3]);
</script>

关于javascript - 在javascript中将文本拆分为数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38789041/

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