我已经trying to convert/differentiate the input岁了,但它不起作用.
这是input-"准点""飞行",我需要创建一个这样的output-""准点"飞行"
The 算法 is whenever you find a phrase in double quotes you must convert that as ""phrase
and single word should be "word".
code:
const _searchKeyword = req.body.fullTextKeyword;
const keywords = _searchKeyword.split(' ');
const formattedKeywords = keywords.map(keyword => {
if (keyword.startsWith('"') && keyword.endsWith('"')) {
// Phrase within double quotes
const phrase = keyword.slice(1, -1);
return `\\"${phrase}\\"`;
} else {
// Single word
return keyword;
}
});
// Join the escaped words with a space.
let concatenatedKeywords = formattedKeywords.join(" ");
但以上code gave me output like this-"准时"\"航班\"
我将如何创建这样的输出,任何帮助都非常感谢!