The pattern that you tried \.(?=.*\.)
matches a dot \.
and uses a positive lookahead (?=
asserting that what is on the right is a dot.
In you example data, that will only match 2 out of 3 dots because for the last dot, the assertion will fail.
If you want to match the last 1 or more consecutive dots, you could use a negative lookahead (?!
instead asserting what is on the right are no more dots following.
\.+(?!.*\.)
Regex demo
If you also want to match the horizontal whitespaces before and after the dots you could add using \h*
\h*\.+\h*(?!.*\.)
Regex demo
You code might look like:
$wptitle = get_the_title($post->id); // getwordpress title
$wptitle = strip_tags($wptitle); // remove a <br> tag
$wptitle = preg_replace('/\h*\.+\h*(?!.*\.)/', ' ', $wptitle);
$wptitle = str_replace('5 Fragen an', '', $wptitle);
echo $wptitle
Note that in your code you use a space in the replacement for the dots.
If you want to remove 5 Fragen an
including an n number of consecutive dots, you could use this pattern and replace with an empty string:
\b5 Fragen an\h+\.+\h+
Regex demo