$re = '/\d{1}\s{16}(\d{4})(\d{9})\s{7}[A-Z\s]{25}(\d{10})[A-Za-z\s]{32}\s{3}\d{1}\d{2}[A-Za-z\s\d]{10}(\d{6})(\d{13})\d{3}\s{5}\d{2}[A-Z]{1}(\d{6})\d{2}\s{2}\d{13}\s{45}\d{2}(\d{14})([A-Z\s]{35})\s{5}([A-Z0-9\s]{40})\s{7}/';
$str = '1 0839854268058 0002611724 101312366 0712170000000020887041 08A24111718 1000000000100 0100001065768010JULIO CEZAR OZORIO DA SILVA BL S AP 202 0200194800000ALVORADA RS 000002';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php