As spotted by Sonarcloud, the regular expression used here might not be safe.
- One could improve the regex or split the processing in multiple steps using JS string methods.
- Or wrap the Regex operation in VM as suggested in SO, which would not work in browser though.