I get a text below this from the database which has multiple strings with double quotes like the one below,
["Time Usage: 9.00am - 4.00pm", "Rental of Commune Room 01 (7 Hours)", "55" Smart TV, 1x Clear Writing Glass, Marker Pen, HDMI Cable, Complimentary WiFi, and Filtered Water"]
Expect Output to Customer
- Time Usage: 9.00am - 4.00pm
- Rental of Commune Room 01 (7 Hours)
- 55" Smart TV, 1x Clear Writing Glass, Marker Pen, HDMI Cable, Complimentary WiFi and Filtered Water
Current Output I get from below code
- Time Usage: 9.00am - 4.00pm,Rental of Commune Room 01 (7 Hours),55" Smart TV
- 1x Clear Writing Glass
- Marker Pen
- HDMI Cable
- Complimentary WiFi
- and Filtered Water
I used the below code,
let description = (["Time Usage: 9.00am - 4.00pm",
"Rental of Commune Room 01 (7 Hours)",
"55\" Smart TV, 1x Clear Writing Glass, Marker Pen, HDMI Cable, Complimentary WiFi, and Filtered Water"]
)
description = description.toString()
description = description.replace(/(\r\n|\n|\r)/gm, '')
if (description !== '') {
description = description.replace(/^/, '* ')
description = description.replace(/,(?=(?:[^"]*"[^"]*")*[^"]*$)/gm, '|')
}
description = description.split('|')
description = description.join('\n * ')
console.log(description);
Can someone helps me to fixed this?