/*
Get a valid UPC-E pattern from UPC-A
NOTE: This gets the pattern only! It does not provide you with parity data
nor does it provide you with check digits, it ignores all that in the input

@param String - UPC-A String
@return String - UPC-E code pattern. Empty string if invalid
function fromUpcA(upcastr) {
  var upca = upcastr.split('');

  if (upca.length == 12) {
    upca.pop();
  }

  var first = upca.shift();
  if (upca.length != 10 || first != 1 && first != 0) {
    return '';
  }

  var upcamask = upca.join(''),
    match = null,
    upce = '';

  // case 0-2
  if (match = upcamask.match(/^([0-9]{2})([0-2])0{4}([0-9]{3})$/ )) {
    upce = match[1] + match[3] + match[2];
  }
  // case 3
  else if (match = upcamask.match(/^([0-9]{3})0{5}([0-9]{2})$/)) {
    upce = match[1] + match[2] + '3';
  }
  // case 4
  else if (match = upcamask.match(/^([0-9]{4})0{5}([0-9])$/)) {
    upce = match[1] + match[2] + '4';
  }
  // case 5-9
  else if (match = upcamask.match(/^([0-9]{5})0{4}([5-9])$/)) {
    upce = match[1] + match[2];
  }

  return upce;
}