Defines a pattern that is used to monitor the response of the
        connected host for a password prompt.

        :type  regex: RegEx
        :param regex: The pattern that, when matched, causes an error.
165897
def set_password_prompt(self, regex=None):
        
        if regex is None:
            self.manual_password_re = regex
        else:
            self.manual_password_re = to_regexs(regex)
273309
def setup_regex(self):
        """"""
        self._RX_INTERFACE = (r"\n\s*interface\s+(?P<name>[a-z0-9_]+)(\s\((?P<symbol>[.\w+*=/-]+)\))?"
                              r"(?P<contents>.+?)"
                              r"end\s*interface\s+(?P=name)?")
        self.RE_INTERFACE = re.compile(self._RX_INTERFACE, re.I | re.DOTALL)
229191
def init_regex(regex)
    optimized_regex=/\A#{regex}/  # anchor the search
    self.parser=lambda do |parent_node|
      offset = parent_node.next
      if parent_node.src[offset..-1].index(optimized_regex)==0
        range = $~.offset(0)
        range = (range.min+offset)..(range.max+offset)
        TerminalNode.new(parent_node,range,regex)
      end
    end
    self.terminal=true
  end
1191714
def regex(self, *pattern, **kwargs):
        
        set_defaults(self._kwargs, kwargs)
        set_defaults(self._regex_defaults, kwargs)
        set_defaults(self._defaults, kwargs)
        pattern = self.rebulk.build_re(*pattern, **kwargs)
        part = ChainPart(self, pattern)
        self.parts.append(part)
        return part
1051630
def get_filter_regex(self):
        
        if self.windowInfoRegex is not None:
            if self.isRecursive:
                return self.windowInfoRegex.pattern
            else:
                return self.windowInfoRegex.pattern
        elif self.parent is not None:
            return self.parent.get_child_filter()
        else:
            return ""
609840
def regex_search(self, regex: str) -> List[HistoryItem]:
        
        regex = regex.strip()
        if regex.startswith(r'/') and regex.endswith(r'/'):
            regex = regex[1:-1]
        finder = re.compile(regex, re.DOTALL | re.MULTILINE)

        def isin(hi):
            """filter function for doing a regular expression search of history"""
            return finder.search(hi) or finder.search(hi.expanded)
        return [itm for itm in self if isin(itm)]
494836
def validate(self, input_string):
        
        validation_result = False
        try:
            validation_result = bool(match(pattern=self.pattern, string=input_string))
        except TypeError as e:
            self.log.error(
                'Exception while validating Regex, pattern={}, input_string={} - exception: {}'.format(self.pattern,
                                                                                                       input_string,
                                                                                                       e))
        return validation_result
511695
def regex_group(ctx, text, pattern, group_num):
    
    text = conversions.to_string(text, ctx)
    pattern = conversions.to_string(pattern, ctx)
    group_num = conversions.to_integer(group_num, ctx)

    expression = regex.compile(pattern, regex.UNICODE | regex.IGNORECASE | regex.MULTILINE | regex.V0)
    match = expression.search(text)

    if not match:
        return ""

    if group_num < 0 or group_num > len(match.groups()):
        raise ValueError("No such matching group %d" % group_num)

    return match.group(group_num)
742347
def _create_regex_if_none(self):
        
        if self._regex is None:
            self._regex = re.compile(self._pattern, re.UNICODE)
1373801
def getmatch(self, regex, group=0, flags=0):
    

    match = self.match(regex, flags)
    if match:
      return match.group(group)
    return None
802279
def regex(self, protocols, localhost=True):
        
        p = r"^"

        # protocol
        p += r"(?:(?:(?:{}):)?//)".format('|'.join(protocols))

        # basic auth (optional)
        p += r"(?:\S+(?::\S*)?@)?"

        p += r"(?:"

        # ip exclusion: private and local networks
        p += r"(?!(?:10|127)(?:\.\d{1,3}){3})"
        p += r"(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})"
        p += r"(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})"

        # ip excluding loopback (0.0.0.0), reserved space (244.0.0.0)
        # and network/broadcast addresses
        p += r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
        p += r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
        p += r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
        p += r"|"

        # hostname
        p += r"(?:"
        p += r"(?:"
        p += r"[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?"
        p += r"[a-z0-9\u00a1-\uffff]"
        p += r"\." if not localhost else r"[\.]?|localhost"


        p += r")+"

        # tld
        p += r"(?:[a-z\u00a1-\uffff]{2,}\.?)"
        p += r")"

        # port (optional)
        p += r"(?::\d{2,5})?"

        # path (optional)
        p += r"(?:[/?#]\S*)?"

        p += r"$"
        return p
928805
def setup_regex(self):
        """"""
        self._RX_CONTAINS = r"^\s*contains[^\n]*?$"
        self.RE_CONTAINS = re.compile(self._RX_CONTAINS, re.M | re.I)

        #Setup a regex that can extract information about both functions and subroutines
        self._RX_EXEC = r"\n[ \t]*((?P<type>character|real|type|logical|integer|complex)?" + \
                        r"(?P<kind>\([a-z0-9_]+\))?)?((?P<modifiers>[\w, \t]+?))?[ \t]*" + \
                        r"(?P<codetype>subroutine|function)\s+(?P<name>[^(]+)" + \
                        r"\s*\((?P<parameters>[^)]*)\)(?P<result>\sresult\([a-z0-9_]+\))?" + \
                        r"(?P<contents>.+?)end\s*(?P=codetype)\s+(?P=name)"
        self.RE_EXEC = re.compile(self._RX_EXEC, re.DOTALL | re.I)
        #Regex for the signature is almost identical to the full executable, but it doesn't
        #look for any contents after the parameter list.
        self._RX_SIG =  r"((?P<type>character|real|type|logical|integer|complex)?" + \
                        r"(?P<kind>\([a-z0-9_]+\))?)?(,?(?P<modifiers>[^\n]+?))?\s*" + \
                        r"(?P<codetype>subroutine|function)\s+(?P<name>[^(]+)" + \
                        r"\s*\((?P<parameters>[^)]*)\)"
        self.RE_SIG = re.compile(self._RX_SIG, re.I)

        #The contents of the executable already have any & line continuations
        #removed, so we can use a simple multiline regex.
        self._RX_ASSIGN = r"^(?P<assignee>[^!<=\n/]+?)=[^\n]+?$"
        self.RE_ASSIGN = re.compile(self._RX_ASSIGN, re.M)

        self._RX_DEPEND = r"^\s*(?P<sub>call\s+)?(?P<exec>[a-z0-9_%]+\s*\([^\n]+)$"
        self.RE_DEPEND = re.compile(self._RX_DEPEND, re.M | re. I)

        self._RX_DEPCLEAN = r"(?P<key>[a-z0-9_%]+)\("
        self.RE_DEPCLEAN = re.compile(self._RX_DEPCLEAN, re.I)

        self._RX_CONST = '[^"\']+(?P<const>["\'][^\'"]+["\'])'
        self.RE_CONST = re.compile(self._RX_CONST)

        self._RX_COMMENTS = r'\s*![^\n"]+?\n'
        self.RE_COMMENTS = re.compile(self._RX_COMMENTS)
133560
def _check_regex(minion_id, regex):
    '''
    
    '''
    get_pillar = False
    for pattern in regex:
        log.debug('nsot external pillar comparing %s with %s', minion_id, regex)
        match = re.search(pattern, minion_id)
        if match and match.string == minion_id:
            log.debug('nsot external pillar found a match!')
            get_pillar = True
            break
        log.debug('nsot external pillar unable to find a match!')
    return get_pillar
718213
def regexp_error_msg(pattern):
    
    try:
        re.compile(pattern)
    except re.error as e:
        return str(e)
    return None
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); };
}
1189932
def visit_regex(self, node, regex):
        """"""
        tilde, literal, flags, _ = regex
        flags = flags.text.upper()
        pattern = literal.literal  # Pull the string back out of the Literal
                                   # object.
        return Regex(pattern, ignore_case='I' in flags,
                              locale='L' in flags,
                              multiline='M' in flags,
                              dot_all='S' in flags,
                              unicode='U' in flags,
                              verbose='X' in flags,
                              ascii='A' in flags)
946092
public static Constraint pattern(final Object regex) {
		return new Constraint("pattern", patternPayload(regex)) {
			public boolean isValid(Object actualValue) {
				if (actualValue != null) {
					if (regex != null && regex instanceof String) {
						if (!(actualValue instanceof String) || !((String) actualValue).matches((String) regex)) {
							return false;
						}
					}
				}
				return true;
			}
		};
	}