How to split a string with dynamic value?

1

I do not know if it's the split you use, in jquery, but I'm not having success. In my code I get the ID value that comes dynamically, I want to split the ID in two. One part up to character 16 and then the rest .. how can I do this?

    
asked by anonymous 28.06.2017 / 15:10

1 answer

1

The following code speaks for itself.

It takes a string value, its dynamic id, and divides it between 2 variables (String):

var id = "suaIDgeradaDinamicamente";
var primeiraParteID = id.substring(0,16);
var segundaParteID = id.substring(16);

console.log("ID :"+id+" - "+id.length);
console.log("Primeira parte da id 0 até 16 caracteres :"+primeiraParteID);
console.log("Segunda parte da id :"+segundaParteID);
    
28.06.2017 / 15:34