I'm sure I'll bang my head against the wall when I read the answer, but I can't figure this one out.
I have a JSON with fake data to populate a db. One property is called "slug" and contains a string that I'd like to "slugify".
So this:
[
{
blah: '[...]'
slug: 'Plem ap at rem',
bleh: '[...]',
},
{
blah: '[...]'
slug: 'Etiam vel augue',
bleh: '[...]',
},
]
Should become:
[
{
blah: '[...]'
slug: 'Plem-ap-at-rem',
bleh: '[...]',
},
{
blah: '[...]'
slug: 'Etiam-vel-augue',
bleh: '[...]',
},
]
I wanted to first target the value and hopelessly capture only the spaces:
slug: '(?:[\w]*([\s])*)+'
I've messed a bit with lookarounds but no luck.
PS: I intend to use it in the VSCode's find&replace, but knowing how would I do this in plain JS is welcome too!