For example, there is a string

<?php $string = "#tag@footbal Последние новости прошедшего дня" ?> 

How can you save this line from tags in the future? Tags may be different, but they look the same: Grid and some text up to the first space.

    1 answer 1

    Write a pattern that will match the substring beginning with the # character, followed by any characters except space. Well, the whitespace symbol is also captured, so that there are no extra spaces after deleting hash tags:

     $string = "#tag@footbal Последние новости прошедшего дня"; $string = preg_replace('~#\S+\s+~', '', $string); echo $string;