Construct an Element instance from regexp
    groups.
163235
def interpret_element(element_type: str, text: str, span: str) -> Element:
    
    return Element(element_type,
                   interpret_span(span),
                   text)
1041595
def from_events(self, instance, ev_args, ctx):
        

        # goal: collect all elements starting with the element for which we got
        # the start-ev_args in a lxml.etree.Element.

        def make_from_args(ev_args, parent):
            el = etree.SubElement(parent,
                                  tag_to_str((ev_args[0], ev_args[1])))
            for key, value in ev_args[2].items():
                el.set(tag_to_str(key), value)
            return el

        root_el = make_from_args(ev_args,
                                 self.__get__(instance, type(instance)))
        # create an element stack
        stack = [root_el]
        while stack:
            # we get send all sax-ish events until we return. we return when
            # the stack is empty, i.e. when our top element ended.
            ev_type, *ev_args = yield
            if ev_type == "start":
                # new element started, create and push to stack
                stack.append(make_from_args(ev_args, stack[-1]))
            elif ev_type == "text":
                # text for current element
                curr = stack[-1]
                if curr.text is not None:
                    curr.text += ev_args[0]
                else:
                    curr.text = ev_args[0]
            elif ev_type == "end":
                # element ended, remove from stack (it is already appended to
                # the current element)
                stack.pop()
            else:
                # not in coverage -- this is more like an assertion
                raise ValueError(ev_type)
126000
private static String buildRegexString(Collection<String> extensions) {
        StringBuilder sb = new StringBuilder();
        Iterator<String> iterator = extensions.iterator();
        while (iterator.hasNext()) {
            String extension = iterator.next();
            sb.append(FILE_EXTENSION_PREFIX_REGEX);
            sb.append(extension);
            if (iterator.hasNext()) {
                sb.append(OR_REGEX);
            }
        }
        return sb.toString();
    }
217351
function arrayToRegexp(arr, keys, options) {
  let parts = [];
  arr.forEach(ele => parts.push(toRegexpSource(ele, keys, options)));
  return new RegExp(`(?:${parts.join('|')})`, flags(options));
}
679236
function glob2regexp(glob, sensitive){
	return new RegExp('^' + glob.replace(ESCAPE_REG_EXP, '\\$1').replace(/\*/g, '.*') + '$', sensitive ? '' : 'i')
}
976309
function(element, name) {
        var names = element.className;
        return (!!names && new RegExp("(^|\\s)" + name + "(\\s|$)").test(names));
    }
1163883
def extend_regex(regexpr):
    
    """
    regex_map = {
        #r'\<': r'\b(?=\w)',
        #r'\>': r'\b(?!\w)',
        r'\<': r'\b' + positive_lookahead(r'\w'),
        r'\>': r'\b' + negative_lookahead(r'\w'),
        ('UNSAFE', r'\x08'): r'\b',
    }
    for key, repl in six.iteritems(regex_map):
        if isinstance(key, tuple):
            search = key[1]
        else:
            search = key
        if regexpr.find(search) != -1:
            if isinstance(key, tuple):
                print('WARNING! Unsafe regex with: %r' % (key,))
            regexpr = regexpr.replace(search, repl)
    return regexpr
47521
def from_elements(cls, elts=None):
        
        node = cls()
        if elts is None:
            node.elts = []
        else:
            node.elts = [const_factory(e) if _is_const(e) else e for e in elts]
        return node
1117088
function(element, className) {
        var re = new RegExp('(\\s|^)'+className+'(\\s|$)');
        if (re.test(element.className)) return;
        element.className += ' ' + className;
      }
5538
function tryCreateRegexp(src, flags, throwErrorAt, parser) {
  try {
    return new RegExp(src, flags);
  } catch (e) {
    if (throwErrorAt !== undefined) {
      if (e instanceof SyntaxError) parser.raise(throwErrorAt, "Error parsing regular expression: " + e.message);
      throw e;
    }
  }
}
514373
def regexNamer(regex, usePageUrl=False):
    """"""
    @classmethod
    def _namer(cls, imageUrl, pageUrl):
        """Get first regular expression group."""
        url = pageUrl if usePageUrl else imageUrl
        mo = regex.search(url)
        if mo:
            return mo.group(1)
    return _namer
724660
function asRegExps(array) {
    var array = asArray(array), len = array.length;
    for (var i = 0; i < len; i++) {
        if (!(array[i] instanceof RegExp)) {
            array[i] = new RegExp(array[i]);
        }
    }
    return array;
}
1277599
def _element_to_bson(key, value, check_keys, opts):
    """"""
    if not isinstance(key, string_type):
        raise InvalidDocument("documents must have only string keys, "
                              "key was %r" % (key,))
    if check_keys:
        if key.startswith("$"):
            raise InvalidDocument("key %r must not start with '$'" % (key,))
        if "." in key:
            raise InvalidDocument("key %r must not contain '.'" % (key,))

    name = _make_name(key)
    return _name_value_to_bson(name, value, check_keys, opts)
1180628
def parse(self, text, element, context='eqn'):
        
        
        # Remove the inline comments from `text` before parsing the grammar
        # http://docs.oasis-open.org/xmile/xmile/v1.0/csprd01/xmile-v1.0-csprd01.html#_Toc398039973
        text = re.sub(r"\{[^}]*\}", "", text)
        
        self.ast = self.grammar.parse(text)
        self.context = context
        self.element = element
        self.new_structure = []
        
        py_expr = self.visit(self.ast)
        
        return ({
            'py_expr': py_expr
        }, self.new_structure)
924772
function(regex) {
  var self = this; var re = new RegExp(regex);
  var keys = {};
  self.init = function() { keys = {}; };
  self.accumulate = function(line) {
    var m = re.exec(line);
    if (m == null) return;
    var k = m[1]; // use 1st group as key
    var v = keys[k];
    if (v) keys[k] = v+1; else keys[k] = 1; // count by key
  };
  self.compensate = function(line) {
    var m = re.exec(line);
    if (m == null) return;
    var k = m[1]; // use 1st group as key
    var v = keys[k];
    if (v) keys[k] = v-1; else keys[k] = 1;
  };
  self.emit = function() {
    return keys;
  };
  self.make = function() { return new WideFinderFunction(regex); };
}
1098931
def visit_generatorexp(self, node):
        """"""
        return "(%s %s)" % (
            node.elt.accept(self),
            " ".join(n.accept(self) for n in node.generators),
        )
1065082
def build_groups(self, tokens):
        """"""
        groups = {}
        for token in tokens:
            match_type = MatchType.start if token.group_end else MatchType.single
            groups[token.group_start] = (token, match_type)
            if token.group_end:
                groups[token.group_end] = (token, MatchType.end)
        return groups