How to hide a particular post with PHP "preg\_replace" or shorter code?

I want to show the **first 5** and **last 5** digits **after `pub-`** of the specified text. The string always starts with `pub-` and there are always **16 numbers in the sequence**. Only the numbers change. I want to replace the middle 6 digits with asterisks.

```
$string = "pub-9752787982789258";

echo "pub-" . substr(explode("-", $string)[1], 0, 5) . '******' . substr(explode("-", $string)[1], 11, 5);

```

RESULT:

```
pub-97527******89258

```