You can split this by . and take the last element of the array - eg
org.apache.cassandra.dht.Murmer3Partitioner becomes just Murmer3Partitioner
Always do this with a split and last element in the array as there could be different packages for the partitioner class to reside under. Also, make sure if it can handle if it is already coming back as Murmer3Partitioner
eg
let strings = [
"org.apache.cassandra.dht.Murmer3Partitioner",
"Murmer3Partitioner"
];
strings.forEach(string => {
let match = string.match(/[^.]+$/);
if (match) {
console.log(match[0]); // Output: Murmer3Partitioner for both cases
} else {
console.log(string); //If something doesnt work, just use the original string
}
});
this long string takes up too much space
You can split this by
.
and take the last element of the array - egorg.apache.cassandra.dht.Murmer3Partitioner
becomes justMurmer3Partitioner
Always do this with a split and last element in the array as there could be different packages for the partitioner class to reside under. Also, make sure if it can handle if it is already coming back as Murmer3Partitioner
eg