fork download
  1. <?php
  2.  
  3. $string = <<<DATA
  4. health status index pri rep docs.count docs.deleted store.size pri.store.size
  5. yellow open first_index 5 1 222173 0 43.8gb 43.8gb
  6. green open second_index 5 1 27131 7 36.6gb 36.6gb
  7. red open third_index 5 1 4047 0 22.4mb 22.4mb
  8. DATA;
  9.  
  10. $regex = '~^(\w+)\W+\w+\W+(\w+)~m';
  11.  
  12. preg_match_all($regex, $string, $matches, PREG_SET_ORDER);
  13.  
  14. foreach ($matches as $match) {
  15. echo $match[2] . "-" . $match[1] . "\n";
  16. }
  17. ?>
Success #stdin #stdout 0.01s 82944KB
stdin
Standard input is empty
stdout
index-health
first_index-yellow
second_index-green
third_index-red