Created
August 13, 2019 18:58
-
-
Save kovalevcon/5014bc44b4715218484287cc3394b779 to your computer and use it in GitHub Desktop.
https://funpay.ru/job.html - тестовое задание
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Parse yandex SMS | |
* | |
* @param string $msg | |
* @return array | |
*/ | |
function parseYandexSMS(string $msg): array | |
{ | |
$yandexCodeRegex = | |
'/^[\W?:\040?]+\s*(?<code>\d{4})[\W?\040?]+\s*(?<amount>\d+,\d+)[\W?\040?]+\s*(?<yandex_account>\d{15})$/'; | |
return preg_match($yandexCodeRegex, $msg, $matches) ? [ | |
'code' => $matches['code'], | |
'amount' => $matches['amount'], | |
'yandex_account' => $matches['yandex_account'], | |
] : []; | |
} | |
$message = 'Пароль: 3131 | |
Спишется 1005,03р. | |
Перевод на счет 410013408143344'; | |
$result = parseYandexSMS($message); | |
var_dump($result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment