-1
這是我的代碼:如何刪除字符串中的換行符?
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (text) {
text.replace(/\r?\n|\r/g, "");
console.log("Command: " + text + "textthatshouldbeinthesameline");
if (text == 'quit') {
console.log("Quitting");
done();
}
});
function done() {
console.log('Now that process.stdin is paused, there is nothing more to do.');
process.exit();
}
這是發生了什麼:
好像有一些換行,我試圖取代他們,但你看:無影響。
當我輸入「quit」時,它也不會被if語句識別。
事實上O.o愚蠢的錯誤,我雖然是更復雜的東西:P – Piotrek