{% renavactive request "^/a_regex" %}
509772
def renavactive(request, pattern):
    
    if re.search(pattern, request.path):
        return getattr(settings, "NAVHELPER_ACTIVE_CLASS", "active")
    return getattr(settings, "NAVHELPER_NOT_ACTIVE_CLASS", "")
1053250
def _lazy_re_compile(regex, flags=0):
    """"""
    def _compile():
        # Compile the regex if it was not passed pre-compiled.
        if isinstance(regex, str):
            return re.compile(regex, flags)
        else:
            assert not flags, "flags must be empty if regex is passed pre-compiled"
            return regex
    return SimpleLazyObject(_compile)
780924
def build_re(self, *pattern, **kwargs):
        
        set_defaults(self._regex_defaults, kwargs)
        set_defaults(self._defaults, kwargs)
        return RePattern(*pattern, **kwargs)
965572
def escape_regex_special_chars(api_path):
    
    def substitute(string, replacements):
        pattern, repl = replacements
        return re.sub(pattern, repl, string)

    return functools.reduce(substitute, REGEX_REPLACEMENTS, api_path)
1274578
function match(re) {
        const m = re.exec(css);

        if (m) {
            css = css.slice(m[0].length);

            return m;
        }
    }
158783
function getRegularExpression(name) {
    // $1: Start Line, $2: Warning Line, $3: Content, $4: MD5 Line, $5: MD5, $6: End Line
    var reAuto      = _.template('(<%= startLine %>)(<%= warningLine %>)((?:.|\n|\r)*?)(<%= md5Line %>)(<%= endLine %>?)');
    var reString    = reAuto({ startLine: autoStartLine(name), warningLine: template.warning(), md5Line: template.md5({ md5: '([a-fA-F0-9]{32})' }), endLine: autoEndLine(name) });
    return new RegExp(reString, 'm');
}
1133996
function (uri) {
	var lastSlash = uri.lastIndexOf("/");
	var sub;
	if (lastSlash == -1) {
		sub = uri;
	} else {
		sub = uri.substr(lastSlash + 1);
	}
	sub = sub.toLowerCase();
	var parsed = parseModuleName(sub);
	var path = removeFiletype(parsed.modulePath || sub);
	var matches = path.match(/^[\w-\s\.]+/);
	return matches ? matches[0] : "";
}
522687
function (remoteUrl) {
      if (remoteUrl.indexOf('http') !== 0) {
        grunt.log.error('Something seems wrong with this remote url: ' + remoteUrl);
      }
      return remoteUrl.toLowerCase().replace('://', '@@').replace(/\?/g, '@');
    }
1075515
def translate_uri(request)
			@@empty_check ||= Regexp.new('^/?$')
			@@lang_check ||= Regexp.new('^/[a-z]{2}(/|$)')
      uri = request.path
      request.uri ||= uri
      config = config(request)
      handle_shortcut(request, config)
      case uri
      when @@empty_check
        request.uri = config['redirect']['/'] ||= @handler_uri
      when @@lang_check
        begin
          self.parse_uri(request)
        rescue LoadError # this happens often
          res = simple_parse_uri(request)
        end
        request.uri = @handler_uri
      end
      Apache::DECLINED
		end
637896
def re_filter(text, regexps):
    """"""
    if not regexps:
        return text

    matched_text = []
    compiled_regexps = [re.compile(x) for x in regexps]
    for line in text:
        if line in matched_text:
            continue

        for regexp in compiled_regexps:
            found = regexp.search(line)
            if found and found.group():
                matched_text.append(line)

    return matched_text or text
434341
function(template, context, partials, in_recursion) {
        // tit for tat
        var that = this;

        var new_regex = function() {
          return new RegExp(that.otag + "(=|!|>|\\{|%)?([^\\/#\\^]+?)\\1?" +
            that.ctag + "+", "g");
        };

        var regex = new_regex();
        var tag_replace_callback = function(match, operator, name) {
          switch(operator) {
          case "!": // ignore comments
            return "";
          case "=": // set new delimiters, rebuild the replace regexp
            that.set_delimiters(name);
            regex = new_regex();
            return "";
          case ">": // render partial
            return that.render_partial(name, context, partials);
          case "{": // the triple mustache is unescaped
            return that.find(name, context);
          default: // escape the value
            return that.escape(that.find(name, context));
          }
        };
        var lines = template.split("\n");
        for(var i = 0; i < lines.length; i++) {
          lines[i] = lines[i].replace(regex, tag_replace_callback, this);
          if(!in_recursion) {
            this.send(lines[i]);
          }
        }

        if(in_recursion) {
          return lines.join("\n");
        }
      }
1242413
def compile_regex(self, fmt, query):
        """"""
        return re.compile(fmt.format(
            query.pattern.replace('.', '\.').replace('*', '[^\.]*').replace(
                '{', '(').replace(',', '|').replace('}', ')')
        ))
1227664
function checkRegexSync (_regex, _config) {
	let pattern;
	let config;

	/* Handle args. */
	try {
		[pattern, config] = handleArgs(_regex, _config);
	} catch (e) {
		log(e);
		log(`Invalid input: _regex ${JSON.stringify(_regex)} _config ${JSON.stringify(_config)}`);
		return RESPONSE_INVALID;
	}
	log(`Input OK. pattern /${pattern}/ config ${JSON.stringify(config)}`);

	/* Check cache to avoid I/O. */
	const cacheHit = checkCache(config, pattern);
	if (cacheHit !== RESPONSE_UNKNOWN) {
		log(`Cache hit: ${cacheHit}`);
		return cacheHit;
	}

	let postObject = generatePostObject(pattern);
	let postBuffer = JSON.stringify(postObject);
	let postHeaders = generatePostHeaders(config, Buffer.byteLength(postBuffer));
	let url = `https://${postHeaders.hostname}:${postHeaders.port}${postHeaders.path}`;

	try {
		log(`sending syncRequest: method ${postHeaders.method} url ${url} headers ${JSON.stringify(postHeaders.headers)} body ${postBuffer}`);

		/* Send request. */
		const response = syncRequest(postHeaders.method, url, {
			headers: postHeaders.headers,
			body: postBuffer
		});

		/* Extract body as JSON. */
		let responseBody;
		try {
			responseBody = response.getBody('utf8');
		} catch (e) {
			log(`checkRegexSync: Unparseable response ${JSON.stringify(response)}`);
			return RESPONSE_INVALID;
		}
		log(`checkRegexSync: I got ${responseBody}`);

		/* Convert to a RESPONSE_X value. */
		const result = serverResponseToRESPONSE(responseBody);
		updateCache(config, postObject.pattern, result);

		return result;
	} catch (e) {
		log(`syncRequest threw: ${JSON.stringify(e)}`);
		return RESPONSE_INVALID;
	}
}
168996
def regex(self):
        """"""
        if not self._compiled_regex:
            self._compiled_regex = re.compile(self.raw)
        return self._compiled_regex
880827
def validate_regex(ctx, param, value):
    
    if not value:
        return None

    try:
        re.compile(value)
    except re.error:
        raise click.BadParameter('Invalid regex "{0}" provided'.format(value))

    return value
527622
function rewrite (raw) {
  var c = raw.charAt(0)
  var path = raw.slice(1)
  if (allowedKeywordsRE.test(path)) {
    return raw
  } else {
    path = path.indexOf('"') > -1
      ? path.replace(restoreRE, restore)
      : path
    return c + 'this.' + path
  }
}
848751
function RouteRule_toRegex(re) {
        var matches = core.match(PATTERN_CAPTURE_REGEX, re), newRegex = re;

        if (matches.length) {
            matches = matches.map(this.toObject);
            matches.forEach(function (item, mIndex) {
                var index = Object.keys(item).length - 3;
                item.isNamed = IS_NAMED.test(item[1]);
                if (item.isNamed) {
                    if (IS_GROUP.test(item[index])) {
                        item.pattern = item[index];
                    } else {
                        item.pattern = '(' + item[index] + ')';
                    }

                    item.key = item[2];
                    newRegex = newRegex.replace(item[0], item.pattern);
                } else {
                    if (IS_GROUP.test(item[index])) {
                        item.pattern = item[index];
                    } else {
                        item.pattern = '(' + item[index] + ')';
                    }
                    item.key = null;
                }
                item.index = mIndex;
            });
            return {
                group: matches,
                regex: core.createRegex(newRegex)
            };
        }
        return {
            group: false,
            regex: core.createRegex(re)
        };
    }