Advertisement
Guest User

Untitled

a guest
Nov 15th, 2018
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.47 KB | None | 0 0
  1. <?php
  2. $input = readline();
  3. $re = '/(?<string>[a-zA-z\W]+)(?<repeat>[\d]+)/m';
  4. preg_match_all($re, $input, $matches, PREG_SET_ORDER, 0);
  5. $finalString = "";
  6. $symbols = "";
  7. for ($i = 0; $i < count($matches); $i++) {
  8.     $finalString .= str_repeat(strtoupper($matches[$i]['string']), $matches[$i]['repeat']);
  9.     $symbols .= strtoupper($matches[$i]['string']);
  10. }
  11. $arr = str_split($symbols);
  12. echo "Unique symbols used: " . count(array_unique($arr)) . PHP_EOL;
  13. echo $finalString;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement