How do I generate a formatted increment ID
neozhu opened this issue · comments
neo.zhu commented
like, ddd-dddd-ddd, xxxx-xxx-xxxx
Jean Lescure commented
Hi @neozhu , I'd say the simplest way would be using regex, like so:
// ddd-dddd-ddd
uid(10).replace(/(.{3})(.{4})(.{3})/g, '$1-$2-$3')
// xxxx-xxx-xxxx
uid(11).replace(/(.{4})(.{3})(.{4})/g, '$1-$2-$3')
Cheers 🍻
neo.zhu commented
cool! thank you.