Suppose we have a specific string that looks like this:
"A - B - C asdas K - A,B,C"
Assume the character delimiter is "-"
The goal is to extract everything before the last occurrence of "-", which in this case would be "A - B - C asdas K ".
An attempted solution involved using the following code snippet:
str = str.split(":").pop();
Is there an alternative method to achieve this task?