I want to remove the date and time stamp on doc_title value in a simpler way. The stamp appears either before or after the name part in the doc_title.
title values
FileName1 (2018-03-07 at 09:00 GMT-8), (2018-03-05 at 06:44 GMT-8) FileName2, (2018-03-05 at 12:15 GMT-8) FileName3, (2018-03-01 at 07:17 GMT-8) FileName4, FileName5 (2018-03-05 at 12:15 GMT-8)
I tried using the logical OR to catch if it's at the end or at the beginning. But it is catching only the first condition.
doc_title = title.split((" \\(")||("\\) "));
Also tried doc_title = title.split((" (") || (") "));
Please help!
You want to retrieve FileName1, FileName2, FileName3, FileName4, FileName5
from FileName1 (2018-03-07 at 09:00 GMT-8), (2018-03-05 at 06:44 GMT-8) FileName2, (2018-03-05 at 12:15 GMT-8) FileName3, (2018-03-01 at 07:17 GMT-8) FileName4, FileName5 (2018-03-05 at 12:15 GMT-8)
. If my understanding is correct, how about this? I think that there are several answers for your situation, so please think of this as one of them.
doc_title = title.replace(/\(\w.+?\)/, "").trim();
var titles = ["FileName1 (2018-03-07 at 09:00 GMT-8)", "(2018-03-05 at 06:44 GMT-8) FileName2", "(2018-03-05 at 12:15 GMT-8) FileName3", "(2018-03-01 at 07:17 GMT-8) FileName4", "FileName5 (2018-03-05 at 12:15 GMT-8)"];
for (var i in titles) {
var doc_title = titles[i].replace(/\(\w.+?\)/, "").trim();
console.log(doc_title)
}
If I misunderstand your question, please tell me. I would like to modify it.