As from the text ssilka-na --- top to make sure that there is at most one dash ssilka-na-top
It is necessary to look in the line --- and replace with - . Or is there an easier way?
As from the text ssilka-na --- top to make sure that there is at most one dash ssilka-na-top
It is necessary to look in the line --- and replace with - . Or is there an easier way?
$mystring = 'ssilka-na---top'; echo preg_replace( '/--+/','-', $mystring ); Replace 2 or more hyphens with one, for example using a regular expression:
$ php -r "var_dump (preg_replace ('/ \ - + /', '-', 'ssilka-na --- top'));"
string (13) "ssilka-na-top"
Source: https://ru.stackoverflow.com/questions/448456/
All Articles
preg_replace( '/\-{2,}/','-', $str );- Visman