I keep seeing this sort of pattern in PHP code, when people match on Regular Expressions:
$orderNumber = 'CLK-TEST001-030';
$pattern = '/([a-z]+)-([a-z]+([0-9]+))?-([0-9]+)/i';
if (preg_match($pattern , $orderNumber, $matches)) {
echo "Prefix was ".$matches[1]." and duration was ".$matches[4];
}
The problem here is that the numbers 4 and 1 are kind of cryptic. Furthermore if the expression changes in future I'll probably need to go through my code and redo the numbering.
A better alternative is to name the groups inside the expression:
$orderNumber = 'CLK-TEST001-030';
$pattern = '/(?<prefix>[a-z]+)-([a-z]+([0-9]+))?-(?<duration>[0-9]+)/i';
if (preg_match($pattern , $orderNumber, $matches)) {
echo "Prefix was ".$matches['prefix'].
" and duration was ".$matches['duration'];
}
This way if the expression gets changed, I can still use the same named fields in my matches in the subsequent code.

