Я схватил (используя мой сценарий) известных людей био в вики. и заметил, что некоторые данные, чтобы эти строки:Удаление строки HIDDEN ERROR
HIDDEN ERROR: Usage of "spouse" is not recognized
HIDDEN ERROR: Usage of "children" is not recognized
Другие био имеют это:
HIDDEN ERROR: Usage of "spouse" is not recognizedHIDDEN ERROR: Usage of "children" is not recognizedHIDDEN ERROR: Usage of "signature" is not recognizedHIDDEN ERROR: Usage of "death_cause" is not recognizedHIDDEN ERROR: Usage of "parents" is not recognizedHIDDEN ERROR: Usage of "resting_place" is not recognized
я делал string.replace().
var start = oldString.indexOf("HIDDEN ERROR");
var end = oldString.indexOf("not recognized");
var toRemove = oldString.substring(start, end);
var newString = oldString.replace(toRemove, ""));
, но не может избавиться от нежелательных линий. Каков наилучший способ удалить эти строки?
Я использовал mongodb для сохранения данных.
Заранее спасибо.
Это выглядит JavaScript. Это? Затем просто используйте 'var newString = oldString.replace (/ HIDDEN \ s + ERROR: \ s + Usage \ s + of \ s +" [^ "] *" \ s + is \ s + not \ s + detected/g, ""); ', см. [this regex demo] (https://regex101.com/r/D59B1c/1). –