- preg_replace: documentation ( source)
- printf: documentation ( source)
<?php
$str = 'asdfnsdfasdjkl <span class="number_box">1.</span> asdfkjsadfasd';
printf (preg_replace('/<span class="number_box">(\d).<\/span>/', '<span class="number_box">$1</span>', $str));