Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. local nr = nil
  2. nr = {next = nr, regex = "^%d%d%d%d%d%d%d" , before="+7888", inplace = nil }
  3. nr = {next = nr, regex = "^38341" , before=nil, inplace = "Berdsk:"}
  4. nr = {next = nr, regex = "^838341" , before=nil, inplace = "Berdsk:"}
  5. nr = {next = nr, regex = "^+738341" , before=nil, inplace = "Berdsk:"}
  6.  
  7. -- точно так же заполняется urir:
  8. local urir = nil
  9. urir = {next = urir, regex = "^89" , before=nil, inplace = "9"}
  10.  
  11. local function canonicValue(param, list)
  12. local node = list
  13. while node do
  14.  
  15. if string.match(param, node.regex) then
  16.  
  17. local matched = string.match(param, node.regex);
  18. local matchedLength = string.len(string.match(param, node.regex));
  19.  
  20. local before = node.before;
  21. local inplace = node.inplace;
  22.  
  23. local result = "";
  24. if before~=nil then
  25. result = result .. before;
  26. end
  27.  
  28. if inplace~=nil then
  29. result = result .. inplace;
  30. else
  31. result = result .. matched;
  32. end
  33.  
  34. result = result .. string.sub(param, matchedLength+1);
  35.  
  36. return result
  37. end
  38.  
  39. node = node.next
  40. end
  41. return param
  42. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement