For example, a jdbc url like this:

```
jdbc:mysql://127.0.0.1:3306/XXXX?useUnicode=true&characterEncoding=utf-8

```

How to replace `XXXX` with `test`.

Expected result is like this:

```
jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf-8

```

***Note:*** `XXXX` is unknown, host ip:host `127.0.0.1:3306` is also unknown. In other words, these two strings are not fixed length.

And `?useUnicode=true&characterEncoding=utf-8` is optional, it means the url maybe:

```
jdbc:mysql://127.0.0.1:3306/XXXX

```

then the result should be 

```
jdbc:mysql://127.0.0.1:3306/test

```

Any help is appreciated, thanks in advance.

***EDIT:*** 
As far as I know, regular expressions would save me, but I can't figure it out.

What I have tried:

```
"jdbc:mysql://127.0.0.1:3306/xxxx?useUnicode=true&characterEncoding=utf-8"
.replaceAll("[^/]+\\?", "test?");

```

but this doesn't work when the url is `jdbc:mysql://127.0.0.1:3306/xxxx`.