I am tring to extract a substring from some text and I am struggling to find the correct sed or regex that will do it for me.

My input text could be one of the following

```
feature/XXX-9999-SomeOtherText
develop
feature/XXX-99999-SomeMoreText
bugfix/XXX-9999
feature/XXXX-9999
XXX-9999

```

and I want to pull out just the XXX-9999, but there can be any number of Xs and 9s. where there are no Xs or 9s (as per the second example) I would like to return an empty value.

I have tried several ways using sed and the closest I got was

```
echo "feature/XXX-9999-SomeOtherText" | sed 's/.*\([[:alpha:]]\{3\}-[[:digit:]]\{4\}\).*/\1/'

```

which works if there are 3 Xs and 4 9s but anything else gives the full input string.