我正在使用 Javascript 来操作 ZOTERO 中的项目。
我有多个项目,其标题包含" : "(空格之间的冒号)。
我想用", "(逗号和空格)替换它。
例如:
This is : an example
Run Code Online (Sandbox Code Playgroud)
应该
This is, an example
Run Code Online (Sandbox Code Playgroud)
谁能告诉.replace我代码中的语句是否正确?
var fieldName = "title";
var fieldID = Zotero.ItemFields.getID(fieldName);
var s = new Zotero.Search();
s.libraryID = ZoteroPane.getSelectedLibraryID();
s.addCondition(fieldName, 'contains', ' ');
var ids = await s.search();
if (!ids.length) {
return "No items found";
}
await Zotero.DB.executeTransaction(async function () {
for (let id of ids) {
let item = await Zotero.Items.getAsync(id);
let mappedFieldID = …Run Code Online (Sandbox Code Playgroud) javascript ×1