I have a string in the format:
"MyGroup/exercise#324242-BC2_asd213"
How can I extract the portion of the string before -
? Specifically, I want to retrieve MyGroup/exercise#324242
. It is important to note that the split should occur after the first instance of -
following the #
, as there may be other instances of -
within the string.
"MyTeam/running-marathon#789098"
In this example, the desired output would be MyTeam/running-marathon#567657
My current method:
.substring(0, vfi.lastIndexOf("-"));
However, I am exploring alternative approaches that are anchor with the "#" symbol for greater precision.