String I get is
["2021-01-13T09:45:48.046Z","2021-01-14T09:45:48.096Z","2021-01-15T09:45:48.099Z"]
Here I want to delete substring from T to Z for converting to this form:
["2021-01-13","2021-01-14","2021-01-15"]
I did like that but it replaces only the first string and deletes others, How can I do this separately for each
notFound=notFound.replace(/\T.*\Z/g, '');
Can I do this with the javascript substring function?
You could replace with an nongready search.
const
data = '["2021-01-13T09:45:48.046Z","2021-01-14T09:45:48.096Z","2021-01-15T09:45:48.099Z"]',
result = data.replace(/T.*?Z/g, '');
console.log(result);
Because you said String so you will have to parse it.
const str = '["2021-01-13T09:45:48.046Z","2021-01-14T09:45:48.096Z","2021-01-15T09:45:48.099Z"]';
let x = JSON.parse(str).map((e) => e.replace(/\T.*\Z/g, ''));
console.log(x);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With