<?php
function _ts_restrictions_translate_ws_message($message = '') {
$source = array(
'The maximum quantity allowed for (\w+) title groups is (\d+) per two-year cycle.',
'The maximum allotment of licenses for this (\w+) title group is (\d+) per two-year cycle.',
'The maximum quantity allowed for (\w+) server products is (\d+) per two-year cycle.',
'Your organization has already requested Get Genuine Full Windows operating system products. This is a one-time-only donation.',
'Get Genuine Windows full operating system requests are subject to a unique approval process, so you cannot combine them with any other products in a single cart. Please remove these products from your cart and complete the check-out process for the remaining products. Then place a second request for the Get Genuine Windows full operating systems.',
'You cannot combine products from the main Microsoft Donations Program with products from the Microsoft Direct Donations Program in a single cart.',
'You must order a minimum of (\d+) seats for (\w+) product orders.',
'You can order a maximum of (\d+) (\w+) items in (\w+). You have already ordered $annualOrdered and can not order any more.',
'You can order a maximum of (\d+) (\w+) items in (\w+). You have already ordered $annualOrdered and can only order (\d+) more.',
'You can order a maximum of (\d+) (\w+) title (\w+) in a fiscal year. You have already ordered (\d+) and can not order any more.',
'You can order a maximum of (\d+) (\w+) title (\w+) in a fiscal year. You have already ordered (\d+) and can only order (\d+) more.',
'There is a limit on the number of times you may request this (\w+) product. The quantity in your cart of product (\w+) exceeds the maximum number of allowable requests.',
);
$matches = array();
foreach ($source as $pattern){
if(preg_match('/'.$pattern.'/', $message, $matches)){
break;
}
}
die(var_dump($matches));
}
_ts_restrictions_translate_ws_message('The maximum quantity allowed for Microsoft title groups is 10 per two-year cycle.');
array(3) {
[0]=>
string(81) "The maximum quantity allowed for Microsoft title groups is 10 per two-year cycle."
[1]=>
string(9) "Microsoft"
[2]=>
string(2) "10"
}