Skip to content
Advertisement

JS Regex named groups with replace()

In JS, I’m trying to build an object from the below code. However I’m stuck at getting regex named groups with the below replace function.

JavaScript

NOTE: What I’m trying to do is, Select characters from str variable from “:” to “,” and replace it with formatters values. Then make the string an object.

Advertisement

Answer

Regex Demo

JavaScript

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement