<?php $text = "Adres: \\4055\\ Esatpaşa mahallesi yeri yurdu sokak no:48 ataşehir\\istanbul"; $matches = preg_match("#(\d+)#si", $text, $matches) ? end($matches) : null; print_r($matches); # 4055