i want this log function to remove the dot and colon
im working on my javascript regular expression
console.log(new Date().toISOString().split('T')[1].replace(/:./g, ''))
my code only remove the colon but not the point
i try different method
console.log(new Date().toISOString().split('T')[1].replace(/:/b./g, ''))
console.log(new Date().toISOString().split('T')[1].replace(/(:)(.)/g, ''))
console.log(new Date().toISOString().split('T')[1].replace(/:&./g, ''))
its always output this format 0510.654Z
anybody know how?
im expecting the output log to remove the colon and point
console.log(new Date().toISOString().split('T')[1].replace(/:./g, ''))
CodePudding user response:
Use a character class you want to replace like this:
console.log(new Date().toISOString().split('T')[1].replace(/[:\.]/g, ''))
CodePudding user response:
You need to update your regex to [.:]
console.log(new Date().toISOString().split('T')[1].replace(/[.:]/g, ''))