我有以下字符串
"sis":4,"sct":15,"ssu":"89c4eef0-3a0d-47ae-a97f-42adafa7cf8f","ssv":384,"siw":96554,"scx":1049,
我需要在“ ssu”之后获取字符串:“结果应该是89c4eef0-3a0d-47ae-a97f-42adafa7cf8f。我该如何在Javascript中执行此操作,但非常简单?我想在“ ssu”之后收集36个字符:”
最佳答案
您可以构建一个有效的JSON字符串并进行解析,然后获取所需的属性ssu
。
var string = '"sis":4,"sct":15,"ssu":"89c4eef0-3a0d-47ae-a97f-42adafa7cf8f","ssv":384,"siw":96554,"scx":1049,',
object = JSON.parse(`{${string.slice(0, -1)}}`), // slice for removing the last comma
ssu = object.ssu;
console.log(ssu);
关于javascript - 提取以Java中的某个单词开头的字符串的一部分,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59347689/