brewersfan1976

is_mac_48_address.rb

Jun 17th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.63 KB | None | 0 0
  1. def isMAC48Address(inputString)
  2.     x = 0
  3.    
  4.     if inputString.length != 17 then
  5.        return false
  6.     end
  7.    
  8.     while (x < inputString.length)
  9.           if (x + 1) % 3 == 0 then
  10.              if inputString[x] != '-' then
  11.                 return false
  12.              end
  13.           end
  14.              
  15.           if (x + 1) % 3 != 0 then
  16.              if (inputString[x] >= '0' and inputString[x] <= '9') or (inputString[x] >= 'A' and inputString[x] <= 'F') then
  17.              else
  18.                 return false
  19.              end
  20.           end
  21.              
  22.           x = x + 1
  23.     end
  24.              
  25.     return true
  26. end
Advertisement
Add Comment
Please, Sign In to add comment