Extract the string between 2 delimiters

using just sed

i am trying to extract the string between 2 delimiters
and print that string to the line above
i cant use the string name as it always different
the delimiters are
: -

this is what i have

https://example.com/live-hls/bla:bob-sd-blabla/playlist.m3u8

and i have tried this but it gets the text between the first : -

sed 's/[^:-]*:\([^:-]*\)-.*/\1/' file

this is whats needed using just sed

bob
https://example.com/live-hls/bla:bob-sd-blabla/playlist.m3u8

thanks

how about for starters:

echo 'https://example.com/live-hls/bla:bob-sd-blabla/playlist.m3u8' | sed 's#.*:\([^-][^-]*\)-.*#\1#'
2 Likes

thanks for reply

that just prints bob

need to print to line above as in post one

Hi

sed 's#.*:\([^-][^-]*\)-.*#\1\n&#'
3 Likes

@nezabudka

that works great
thank you