Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

generate uuid from string js

const stringToUuid = (str) => {
  str = str.replace('-', '');
  return 'xxxxxxxx-xxxx-4xxx-xxxx-xxxxxxxxxxxx'.replace(/[x]/g, function(c, p) {
    return str[p % str.length];
  });
}

var input  = "813538-359512";
var output = stringToUuid(input);

console.log('Input: ' + input);
console.log('Output: ' + output);
Comment

PREVIOUS NEXT
Code Example
Javascript :: js get index of item in array 
Javascript :: js match any number string 
Javascript :: javascript copy items into another array 
Javascript :: javaScript getHours() Method 
Javascript :: variable used in a function can be used in another function js 
Javascript :: javascript change all text color 
Javascript :: javascript fetch request GET 
Javascript :: string repeat javascript 
Javascript :: detect adblock javascript 
Javascript :: index of row jquery 
Javascript :: how to export a function in nodejs 
Javascript :: sending value in input angular material 
Javascript :: componentwillreceiveprops hooks 
Javascript :: javascript disable div 
Javascript :: how to tell what page you are on shopify liquid 
Javascript :: react usecallback 
Javascript :: using underscore javascript number 
Javascript :: how to use javascript in flutter 
Javascript :: init select2 jquery 
Javascript :: javascript remove uniques from array 
Javascript :: capitalize mdn 
Javascript :: new map js 
Javascript :: form validation jquery input array 
Javascript :: password validation with regular expression in javascript 
Javascript :: element remove class 
Javascript :: chrome storage local example 
Javascript :: console log vuex in production 
Javascript :: js map size 
Javascript :: base64 encode in javascript 
Javascript :: $.post javascript 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =