如何在我的React应用程序的json中的段落中提取特定句子?

时间:2018-07-24 11:28:00

标签: javascript html json reactjs

我想在我的react应用程序的Json内的段落中拉特定的句子。例如-

groupinfo: this is the groups info
errorInfo: "imagine this is a long paragraph within a Json file, and i want to display/pull just a small part of it. so for instance i want just (long paragraph) and I want to know how to just pull that one part of the paragraph"

我想使用本段的这一小部分来完成网络链接,因此它所使用的一小段句子必须是可变的,并且要根据json中的artifactID来确定。

因此,如果要执行该操作,它将只在Json中拉出该段落的一小部分,并将其显示为指向网站的链接。如果我需要做更多的解释,请告诉我。

1 个答案:

答案 0 :(得分:-1)

如果带有子字符串,该怎么办?

const myStr = 'Alligator';

const myNewStr = myStr.substring(0, 3);

console.log(myNewStr); // All