<?php $re = '/(?:\G(?!^)|(?=(?:[e-g]\d+)+c))[e-g]\d+/'; $str = 'e123f654g933c and e123f654g933ce99f77g66c';
Standard input is empty
Array
(
[0] => e123
[1] => f654
[2] => g933
[3] => e123
[4] => f654
[5] => g933
[6] => e99
[7] => f77
[8] => g66
)