Return complement of pattern in string
328666
def _strip(string, pattern):
    """"""
    m = re.compile(pattern).search(string)

    if m:
        return string[0:m.start()] + string[m.end():len(string)]
    else:
        return string
793877
function _getValueFromPair(string, pattern) {
         var value = string.match(pattern);

         if (!value) {
           throw new Error("Could not find pattern " + pattern + " in string: " + string);
         }

         return value[0].split("=")[1];
       }
479058
def pattern(head, *args, mode=1, wc_name=None, conditions=None, **kwargs) \
        -> Pattern:
    """'
    """
    if len(args) == 0:
        args = None
    if len(kwargs) == 0:
        kwargs = None
    return Pattern(head, args, kwargs, mode=mode, wc_name=wc_name,
                   conditions=conditions)
766131
function normalizePattern(
  pattern /*: string*/,
) /*: {
  hasVersion: boolean,
  name: string,
  range: string,
}*/ {
  let hasVersion = false
  let range = 'latest'
  let name = pattern

  // if we're a scope then remove the @ and add it back later
  let isScoped = false
  if (name[0] === '@') {
    isScoped = true
    name = name.slice(1)
  }

  // take first part as the name
  const parts = name.split('@')
  if (parts.length > 1) {
    name = parts.shift()
    range = parts.join('@')

    if (range) {
      hasVersion = true
    } else {
      range = '*'
    }
  }

  // add back @ scope suffix
  if (isScoped) {
    name = `@${name}`
  }

  return {name, range, hasVersion}
}
1029629
def REGEX(pattern, flags=0):
    """"""
    return P(lambda x: re.match(pattern, x, flags=flags))
874396
function asRegExp(pattern) {
  // if regex then return it
  if (isRegExp(pattern)) {
    return pattern;
  }

  // if string then test for valid regex then convert to regex and return
  const match = pattern.match(REGEX);
  if (match) {
    return new RegExp(match[1], match[2]);
  }

  return new RegExp(pattern);
}
770601
private Pattern getPattern(String expr)
    {
        Pattern pattern = patterns.get(expr);
        if(pattern == null)
        {
            pattern = Pattern.compile(expr);
            patterns.put(expr, pattern);
        }
        return pattern;
    }
1194274
function( string ) {
    var negated, matches, patterns = this.patterns, i = patterns.length;
    while ( i-- ) {
      negated = patterns[ i ].negated;
      matches = patterns[ i ].matcher( string );
      if ( negated !== matches ) {
        return matches;
      }
    }
    return false;
  }
387050
function strRepeat(str, n) {
    var res = '';
    do {
        if (n & 1) {
            res += str;
        }

        str += str;
    } while (n = n >> 1);

    return res;
}
776641
def _get_span(s, pattern):
    """"""
    i, j = -1, -1

    match = pattern.match(s)
    if not match:
        return i, j

    for group_name in pattern.groupindex:
        i, j = match.span(group_name)
        if (i, j) != (-1, -1):
            return i, j

    return i, j
1080015
def decode_complementarity(comp, control):

    '''
    
    '''

    try:
        res = regex.match(comp).groups()
    except:
        raise Exception("Unable to parse complementarity condition '{}'".format(comp))
    res = [r.strip() for r in res]
    if res[1] != control:
        msg = "Complementarity condition '{}' incorrect. Expected {} instead of {}.".format(comp, control, res[1])
        raise Exception(msg)
    return [res[0], res[2]]
882846
def scan(pattern, string, *args, **kwargs):
    
    return compile(pattern, *args, **kwargs).scan(string)
219150
def parse_pattern(s):
    """"""
    if '{' in s:
        return None, None  # Unsupported by fnmatch
    if s and s[0] == '~':
        s = os.path.expanduser(s)
    parts = s.split('/')
    absolute = len(parts) > 1 and not parts[0]
    if parts[-1] == '':  # # Outcome of trailing /
        parts = parts[:-1]  # discard
    if len(parts) == 0:
        directory = ''
        pattern = ''
    else:
        directory = '/'.join(parts[:-1])
        pattern = parts[-1]
    if not is_pattern(directory): # Check for e.g. /abc/*/def
        if is_pattern(pattern):
            if not directory:
                directory = '/' if absolute else '.'
            return directory, pattern
    return None, None
282488
def matches_pattern(self, other):
        """"""
        matches = False
        if hasattr(other, 'addr'):
            if self.addr is None or other.addr is None:
                matches = True
            else:
                matches = self.addr == other.addr
        return matches
25287
def accept_re(regexp, buf, pos):
    """"""
    match = regexp.match(buf, pos)
    if not match:
        return None, pos
    return buf[match.start(1):match.end(1)], match.end(0)
498319
def match(self, string):
        """"""
        if self.casesensitive:
            return fnmatch.fnmatch(string, self.pattern)
        else:
            return fnmatch.fnmatch(string.lower(), self.pattern.lower())
132313
def ismatch(text, pattern):
    """"""

    if hasattr(pattern, 'search'):
        return pattern.search(text) is not None
    else:
        return pattern in text if Config.options.case_sensitive \
            else pattern.lower() in text.lower()