Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to remove dashes in UUID with nodejs?

I’m trying to remove the dashes in the UUID by using the replace function on NodeJS but unsuccessful as it always returns with dashes.

const { v4: uuidv4 } = require('uuid');

const uuid = uuidv4().toString()

console.log(uuid.replace("-",""))

The code above is what I’m trying to do to remove the dashes. Thanks

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

function replace only try 1 times

you can replace all ‘-‘ use RegExp like this:

uuid.replace(/-/gi, '');
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading