I have got this string:

```
tcp://10.0.0.1:11211?rep=12&timeout=12

```

so I tried with:

```
(tcp://.+):([0-9]+)\?.*\&+timeout=([0-9]+).*

```

I need to retrieve:

* `tcp://10.0.0.1` that is the server
* `11211` that is the port
* `timeout` parameter value (in this case 12)

The `tcp://10.0.0.1:11211` part exists in any case and so I need it, but the query part is not mandatory, so my problem is that if `?` or `timeout` or `=` don't exist the regex doesn't retrun anything.  

Due to my inexperience I'm not able to solve this problem,how can I achive this result?

[Regex101 Demo](https://regex101.com/r/uN1mX7/1)