replacing national prefix to simplified format
972189
def with_replaced_national_prefix(phone, data)
      return phone unless data[Core::NATIONAL_PREFIX_TRANSFORM_RULE]
      pattern = cr("^(?:#{data[Core::NATIONAL_PREFIX_FOR_PARSING]})")
      match = phone.match pattern
      if match && match.captures.compact.size > 0
        phone.gsub(pattern, data[Core::NATIONAL_PREFIX_TRANSFORM_RULE])
      else
        phone
      end
    end
650774
def strip_prefix(string, prefix, regex=False):
    """"""
    if not isinstance(string, six.string_types) or not isinstance(prefix, six.string_types):
        msg = 'Arguments to strip_prefix must be string types. Are: {s}, {p}'\
              .format(s=type(string), p=type(prefix))
        raise TypeError(msg)

    if not regex:
        prefix = re.escape(prefix)
    if not prefix.startswith('^'):
        prefix = '^({s})'.format(s=prefix)
    return _strip(string, prefix)
1036371
def ns_prefix(self, prefix, ns_uri):
        
        self._element.set_ns_prefix(prefix, ns_uri)
        return self
141323
def uri_from_fields(prefix, *fields):
        """"""
        string = '_'.join(AlignmentHelper.alpha_numeric(f.strip().lower(), '') for f in fields)

        if len(string) == len(fields) - 1:
            return ''

        return prefix + string
375832
def trim_common_prefixes(strs, min_len=0):
    """"""

    trimmed = 0

    if len(strs) > 1:
        s1 = min(strs)
        s2 = max(strs)

        for i in range(len(s1) - min_len):
            if s1[i] != s2[i]:
                break
            trimmed = i + 1

    if trimmed > 0:
        strs = [s[trimmed:] for s in strs]

    return trimmed, strs
1270644
def untranslateName(s):
    """"""

    s = s.replace('DOT', '.')
    s = s.replace('DOLLAR', '$')
    # delete 'PY' at start of name components
    if s[:2] == 'PY': s = s[2:]
    s = s.replace('.PY', '.')
    return s
1211062
def standardizeMapName(mapName):
    """"""
    #print("foreignName: %s  (%s)"%(mapName, mapName in c.mapNameTranslations))
    #if mapName in c.mapNameTranslations:
    #    return c.mapNameTranslations[mapName]
    newName = os.path.basename(mapName)
    newName = newName.split(".")[0]
    newName = newName.split("(")[0]
    newName = re.sub("[LT]E+$", "", newName)
    newName = re.sub("-", "", newName)
    newName = re.sub(' ', '', newName, flags=re.UNICODE)
    foreignName = newName#bytes(mapName, 'utf-16')
    #print("foreignName: %s  (%s)"%(foreignName, foreignName in c.mapNameTranslations))
    if foreignName in c.mapNameTranslations:
        return c.mapNameTranslations[foreignName]
    return newName
296031
def _prefix_from_uri(self, uriname):
        
        uripart, tag = uriname.split('}', maxsplit=1)
        uri = uripart.replace('{', '')
        return self.REVERSE_NS[uri] + ':' + tag
710411
def n2s(self, offset, length):
        """"""
        s = ''
        for dummy in range(length):
            if self.endian == 'I':
                s += chr(offset & 0xFF)
            else:
                s = chr(offset & 0xFF) + s
            offset = offset >> 8
        return s
152652
def _attempt_to_format_accrued_digits(self):
        
        for number_format in self._possible_formats:
            num_re = re.compile(number_format.pattern)
            if fullmatch(num_re, self._national_number):
                if number_format.national_prefix_formatting_rule is None:
                    self._should_add_space_after_national_prefix = False
                else:
                    self._should_add_space_after_national_prefix = bool(_NATIONAL_PREFIX_SEPARATORS_PATTERN.search(number_format.national_prefix_formatting_rule))
                formatted_number = re.sub(num_re, number_format.format, self._national_number)
                return self._append_national_number(formatted_number)
        return U_EMPTY_STRING
573216
def nf_input_to_cl(inp):
    
    sep = " " if inp.get("separate") else ""
    val = "'%s'" % inp.get("default") if inp.get("default") else "$%s" % inp["name"]
    return "%s%s%s" % (inp["prefix"], sep, val)
636236
def _commonprefix(m):
    ""
    if not m:
        return ''
    prefix = m[0]
    for item in m:
        for i in range(len(prefix)):
            if prefix[:i+1] != item[:i+1]:
                prefix = prefix[:i]
                if i == 0:
                    return ''
                break
    return prefix
287226
def _format_numer(number_format, prefix='', suffix=''):
    """"""
    @_surpress_formatting_errors
    def inner(v):
        if isinstance(v, Number):
            return ("{{}}{{:{}}}{{}}"
                    .format(number_format)
                    .format(prefix, v, suffix))
        else:
            raise TypeError("Numberic type required.")
    return inner
1027416
def strip_optional_prefix(string, prefix, log=None):
    
    if string.startswith(prefix):
        return string[len(prefix):]
    if log:
        log.warn('String starts with %r, not %r', string[:len(prefix)], prefix)
    return string
15461
def _format_name_map(self, lonc, latc):
        '''  '''

        return '_'.join(['WAC', 'GLOBAL'] +
                        ['E' + latc + lonc, "{0:0>3}".format(self.ppd) + 'P'])
668991
def convert_fus(ast):
    """"""

    parent_fn_name = ast.name_short
    prefix_list = {"p": "p.", "r": "r.", "g": "c."}
    prefix = prefix_list[parent_fn_name]

    fus1_ns = ast.args[0].namespace
    fus1_val = ast.args[0].value

    arg_fus = ast.args[1]
    fus_args = [None, "?", "?"]
    for idx, arg in enumerate(arg_fus.args):
        fus_args[idx] = arg

    fus2_ns = fus_args[0].namespace
    fus2_val = fus_args[0].value

    if fus_args[1] == "?":
        fus1_range = fus_args[1]
    else:
        fus1_range = f'"{prefix}1_{fus_args[1].value}"'

    if fus_args[2] == "?":
        fus2_range = fus_args[2]
    else:
        fus2_range = f'"{prefix}{fus_args[2].value}_?"'

    fus = Function("fus", spec, parent_function=ast)
    fus.args = [
        NSArg(fus1_ns, fus1_val, fus),
        StrArg(fus1_range, fus),
        NSArg(fus2_ns, fus2_val, fus),
        StrArg(fus2_range, fus),
    ]

    # Remove BEL
    ast_args = ast.args
    ast_args.pop(0)
    ast_args.pop(0)

    if ast_args == [None]:
        ast_args = []

    ast.args = []
    ast.add_argument(fus)

    if len(ast_args) > 0:
        ast.args.extend(ast_args)

    return ast
900464
function removePrefix(str, prefixToken) {
  const index =  str.indexOf(prefixToken);

  if (index > -1) {
    str = str.substr(index + prefixToken.length).trim();
  }
  return str;
}