I'm having trouble capturing the digits in a string of this format `(t|b|bug_|task_|)1234` using a bash regex. The below doesn't work:

```
[[ $current_branch =~ ^(t|b|bug_|task_|)([0-9]+) ]]

```

But once I change it to something like this:

```
[[ $current_branch =~ ^(t|b|bug_|task_)([0-9]+) ]]

```

it works, but of course its wrong because it doesn't cover the case where there are no prefixes. I realize in this case I could do

```
[[ $current_branch =~ ^(t|b|bug_|task_)?([0-9]+) ]]

```

and achieve the same result, but I'd like to know why the 2nd example doesn't work. That regex seems to work fine in Ruby, for example.

(This is on `GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin11)`, OSX Lion)