I need a regex for the following pattern:
a single character from [e-g] followed by one or more numbers that ends with character 'c'.
for example e123f654g933c expected result:
Array
(
[0] => Array
(
[0] => e123
[1] => f654
[2] => g933
)
)
or
e123f654g933ce99f77g66c expected result:
Array
(
[0] => Array
(
[0] => e123
[1] => f654
[2] => g933
),
[1] => Array
(
[0] => e99
[1] => f77
[2] => g66
)
)
I tried using the following but I don't know what to do with 'c' part. I used this ([e-g]{1}[0-9]{1,}c)+ but it fails.
$subject="e123f654g933ce99f786g776c";
preg_match_all('/[e-g]{1}[0-9]{1,}/', $subject, $match);
print '<pre>' . print_r($match,1) . '</pre>';
Array
(
[0] => Array
(
[0] => e123
[1] => f654
[2] => g933
[3] => e99
[4] => f786
[5] => g776
)
)
thanks.