fork download
  1. <?php
  2.  
  3. $str = 'текст ДПБ02 текст еще';
  4. echo $str . PHP_EOL;
  5. if (preg_match_all('/([А-Я]*)(\d*)/iu', $str, $matches, PREG_SET_ORDER)) {
  6. foreach ($matches as $index => $match) {
  7. if (count(array_filter($match))) {
  8. echo '#' . $index . ' ' . $match['1'] . ' ' . $match['2'] . PHP_EOL;
  9. }
  10. }
  11. }
Success #stdin #stdout 0.01s 82624KB
stdin
Standard input is empty
stdout
текст ДПБ02 текст еще
#0 текст 
#2 ДПБ 02
#4 текст 
#6 еще