There is a line Parish number 5146 12/12/2018 Name Go how to get = No. 5146 12/12/2018 Name

$str = ' Приход № 5146 12/12/2018 Имя'; $number = preg_replace("/[^№ \/ 0-9]/", '', $str); ответ № 5146 12/12/2018, а имя не получается в конце подставить. 
  • one
    why not just delete the Приход ? - teran

2 answers 2

the name does not work at the end to substitute

If using preg_replace () , then the template should capture only those characters that need to be deleted:

 $str = ' Приход № 5146 12/12/2018 Имя'; $str = preg_replace('~.+?(?=№.+)~', '', $str); echo $str; // № 5146 12/12/2018 Имя 

    As a variant without a regular expression:

     $str = ' Приход № 5146 12/12/2018 Имя'; echo stristr($str, '№');