【发布时间】:2022-11-15 19:26:36
【问题描述】:
我在数据库表中有一列,其中保存类型字符串。它保存由分号分隔的多行,就像这样 -
this is first sentence;this is second sentence;this is third sentence
我只想打印第一行,即 -
this is first sentence
知道如何使用 JavaScript 实现吗?
【问题讨论】:
标签: javascript
我在数据库表中有一列,其中保存类型字符串。它保存由分号分隔的多行,就像这样 -
this is first sentence;this is second sentence;this is third sentence
我只想打印第一行,即 -
this is first sentence
知道如何使用 JavaScript 实现吗?
【问题讨论】:
标签: javascript
使用String.prototype.split
const string ='this is first sentence;this is second sentence;this is third sentence'
const sentences = string.split(';')
const first = sentences[0]
console.log(first)
【讨论】: