fork(2) download
  1. <?php
  2.  
  3. $mystring = "ABEH A501; BIOL L340; BIOL Z620; Q799; ABEH A501";
  4.  
  5. echo preg_replace('/[a-zA-Z]{4}\s+[a-zA-Z]\d{3}(*SKIP)(*F)|\w+\W*/', '', $mystring);
Success #stdin #stdout 0s 82944KB
stdin
Standard input is empty
stdout
ABEH A501; BIOL L340; BIOL Z620; ABEH A501