so i have string like this
accept : menerima
accuse : menuduh
achieve : mencapai
acquire : memperoleh
adapt : menyesuaikan
add : menambahkan
and how to delete the second word using : as separator,
And make the result like this.
accept
accuse
achieve
acquire
adapt
add
thanks
>Solution :
A different approach to a regex would be to loop over the lines, and split the : using a map.
const string = `accept : menerima
accuse : menuduh
achieve : mencapai
acquire : memperoleh
adapt : menyesuaikan
add : menambahkan`;
const lines = string.split("\n")
.map((line) => line.split(" : ")[0])
// Optionally if you would like to return the output as a single string
.join("\n");
console.log(lines);