[ticket/10423] Match multiple wildcards

Multiple wildcards are removed from the string if there is
no word before or after them. If there is a word before or
after them, they are just replaced with a single one.

PHPBB3-10423