Given the following input format:
blablabla-blebleble-bliblibli-1.2.3-xxx-1blo
I want to have 2 regex to get:
blablabla-blebleble-bliblibli1.2.3-xxx-1blo
There's no guarantee that the first part ('blablabla-blebleble-bliblibli') will always have two -, but it's 100% certain that the second part ('1.2.3-xxx-1blo') will always have two -, and between part one and two will always have -
I managed to do this using cut but it's slow for massive operations. So I'm hoping that using bash regex can improve performance. Also, I tried this [^-]+(?:-[^-]+){2}$ in regex101.com and it works, but in bash it doesn't:
test='blablabla-blebleble-bliblibli-1.2.3-xxx-1blo'
[[ $test =~ [^-]+(?:-[^-]+){2}$ ]]; echo $BASH_REMATCH