Compiles regular expression used for parsing SMS messages based on current mode
4994
def _compileSmsRegexes(self):
        
        if self._smsTextMode:
            if self.CMGR_SM_DELIVER_REGEX_TEXT == None:
                self.CMGR_SM_DELIVER_REGEX_TEXT = re.compile(r'^\+CMGR: "([^"]+)","([^"]+)",[^,]*,"([^"]+)"$')
                self.CMGR_SM_REPORT_REGEXT_TEXT = re.compile(r'^\+CMGR: ([^,]*),\d+,(\d+),"{0,1}([^"]*)"{0,1},\d*,"([^"]+)","([^"]+)",(\d+)$')
        elif self.CMGR_REGEX_PDU == None:
            self.CMGR_REGEX_PDU = re.compile(r'^\+CMGR: (\d*),"{0,1}([^"]*)"{0,1},(\d+)$')
646740
def parse(self, string, parent):
        """"""
        result = {}
        for member in self.RE_MEMBERS.finditer(string):
            mems = self._process_member(member, parent, string)
            #The regex match could contain multiple members that were defined
            #on the same line in the code file.
            for onemem in mems:
                result[onemem.name.lower()] = onemem
                
        return result
1167740
static function matchText( &$text, $match_pre, $match_post )
    {
        $ret = null;
        if ( $match_pre !== '' )
        {
            $pos = strpos( $text, $match_pre );
            if ( $pos === false )
                return null;

            $ret = substr( $text, $pos + strlen( $match_pre ) );
            $text = substr( $text, 0, $pos );
        }
        if ( $match_post !== '' )
        {
            $pos = strpos( $ret, $match_post );
            if ( $pos === false )
                return null;

            $text .= substr( $ret, $pos + 1 );
            $ret = substr( $ret, 0, $pos );
        }
        return $ret;
    }
177218
def markup(self, text, escape=None, funcs={}, classes={}, methods={}):
        """"""
        escape = escape or self.escape
        results = []
        here = 0

        # XXX Note that this regular expression does not allow for the
        # hyperlinking of arbitrary strings being used as method
        # names. Only methods with names consisting of word characters
        # and '.'s are hyperlinked.
        pattern = re.compile(r'\b((http|ftp)://\S+[\w/]|'
                                r'RFC[- ]?(\d+)|'
                                r'PEP[- ]?(\d+)|'
                                r'(self\.)?((?:\w|\.)+))\b')
        while 1:
            match = pattern.search(text, here)
            if not match: break
            start, end = match.span()
            results.append(escape(text[here:start]))

            all, scheme, rfc, pep, selfdot, name = match.groups()
            if scheme:
                url = escape(all).replace('"', '&quot;')
                results.append('<a href="%s">%s</a>' % (url, url))
            elif rfc:
                url = 'http://www.rfc-editor.org/rfc/rfc%d.txt' % int(rfc)
                results.append('<a href="%s">%s</a>' % (url, escape(all)))
            elif pep:
                url = 'http://www.python.org/dev/peps/pep-%04d/' % int(pep)
                results.append('<a href="%s">%s</a>' % (url, escape(all)))
            elif text[end:end+1] == '(':
                results.append(self.namelink(name, methods, funcs, classes))
            elif selfdot:
                results.append('self.<strong>%s</strong>' % name)
            else:
                results.append(self.namelink(name, classes))
            here = end
        results.append(escape(text[here:]))
        return ''.join(results)
1124851
function parseScopeSyntax(text) {
    // the regex below was built using the following pseudo-code:
    // double_quoted_string = `"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"`
    // single_quoted_string = `'[^'\\\\]*(?:\\\\.[^'\\\\]*)*'`
    // text_out_of_quotes = `[^"']*?`
    // expr_parts = double_quoted_string + "|" + single_quoted_string + "|" + text_out_of_quotes
    // expression = zeroOrMore(nonCapture(expr_parts)) + "?"
    // id = "[$_a-zA-Z]+[$_a-zA-Z0-9]*"
    // as = " as" + OneOrMore(" ")
    // optional_spaces = zeroOrMore(" ")
    // semicolon = nonCapture(or(text(";"), "$"))
    //
    // regex = capture(expression) + as + capture(id) + optional_spaces + semicolon + optional_spaces

    const regex = RegExp("((?:(?:\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"|'[^'\\\\]*(?:\\\\.[^'\\\\]*)*'|[^\"']*?))*?) as(?: )+([$_a-zA-Z]+[$_a-zA-Z0-9]*)(?: )*(?:;|$)(?: )*", 'g')
    const res = []
    do {
        const idx = regex.lastIndex
        const match = regex.exec(text)
        if (regex.lastIndex === idx || match === null) {
            throw text.substr(idx)
        }
        if (match.index === regex.lastIndex) {
            regex.lastIndex++
        }
        res.push({expression: match[1].trim(), identifier: match[2]})
    } while (regex.lastIndex < text.length)

    return res
}
1342178
def _compile_messages(self):
        '''
        
        '''
        self.compiled_messages = []
        if not self._config:
            return
        for message_dict in self._config.get('messages', {}):
            error = message_dict['error']
            tag = message_dict['tag']
            model = message_dict['model']
            match_on = message_dict.get('match_on', 'tag')
            if '__python_fun__' in message_dict:
                self.compiled_messages.append({
                    'error': error,
                    'tag': tag,
                    'match_on': match_on,
                    'model': model,
                    '__python_fun__': message_dict['__python_fun__']
                })
                continue
            values = message_dict['values']
            line = message_dict['line']
            mapping = message_dict['mapping']
            # We will now figure out which position each value is in so we can use it with the match statement
            position = {}
            replace = {}
            for key in values.keys():
                if '|' in key:
                    new_key, replace[new_key] = key.replace(' ', '').split('|')
                    values[new_key] = values.pop(key)
                    key = new_key
                position[line.find('{' + key + '}')] = key
            sorted_position = {}
            for i, elem in enumerate(sorted(position.items())):
                sorted_position[elem[1]] = i + 1
            # Escape the line, then remove the escape for the curly bracets so they can be used when formatting
            escaped = re.escape(line).replace(r'\{', '{').replace(r'\}', '}')
            # Replace a whitespace with \s+
            escaped = escaped.replace(r'\ ', r'\s+')
            self.compiled_messages.append(
                {
                    'error': error,
                    'tag': tag,
                    'match_on': match_on,
                    'line': re.compile(escaped.format(**values)),
                    'positions': sorted_position,
                    'values': values,
                    'replace': replace,
                    'model': model,
                    'mapping': mapping
                }
            )
        log.debug('Compiled messages:')
        log.debug(self.compiled_messages)
505151
function (regexp) {
        var res = maybeCallNative(nativeMatch, regexp, this);
        if (res.done) return res.value;

        var rx = anObject(regexp);
        var S = String(this);

        if (!rx.global) return regExpExec(rx, S);

        var fullUnicode = rx.unicode;
        rx.lastIndex = 0;
        var A = [];
        var n = 0;
        var result;
        while ((result = regExpExec(rx, S)) !== null) {
          var matchStr = String(result[0]);
          A[n] = matchStr;
          if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
          n++;
        }
        return n === 0 ? null : A;
      }
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)
409255
function(msg) {
        var nick_hex, time_difference,
            message_words,
            sb = this.model.get('scrollback'),
            network = this.model.get('network'),
            nick,
            regexpStr,
            prev_msg = sb[sb.length-2],
            hour, pm, am_pm_locale_key;

        // Clone the msg object so we dont modify the original
        msg = _.clone(msg);

        // Defaults
        msg.css_classes = '';
        msg.nick_style = '';
        msg.is_highlight = false;
        msg.time_string = '';

        // Nick + custom highlight detecting
        nick = network ? network.get('nick') : '';
        if (nick && msg.nick.localeCompare(nick) !== 0) {
            // Build a list of all highlights and escape them for regex
            regexpStr = _.chain((_kiwi.global.settings.get('custom_highlights') || '').split(/[\s,]+/))
                .compact()
                .concat(nick)
                .map(_.escapeRegExp)
                .join('|')
                .value();

            if (msg.msg.search(new RegExp('(\\b|\\W|^)(' + regexpStr + ')(\\b|\\W|$)', 'i')) > -1) {
                msg.is_highlight = true;
                msg.css_classes += ' highlight';
            }
        }

        message_words = msg.msg.split(' ');
        message_words = _.map(message_words, function(word) {
            var parsed_word;

            parsed_word = this.parseMessageUrls(word);
            if (typeof parsed_word === 'string') return parsed_word;

            parsed_word = this.parseMessageChannels(word);
            if (typeof parsed_word === 'string') return parsed_word;

            parsed_word = this.parseMessageNicks(word, (msg.type === 'privmsg'));
            if (typeof parsed_word === 'string') return parsed_word;

            parsed_word = _.escape(word);

            // Replace text emoticons with images
            if (_kiwi.global.settings.get('show_emoticons')) {
                parsed_word = emoticonFromText(parsed_word);
            }

            return parsed_word;
        }, this);

        msg.unparsed_msg = msg.msg;
        msg.msg = message_words.join(' ');

        // Convert IRC formatting into HTML formatting
        msg.msg = formatIRCMsg(msg.msg);

        // Add some style to the nick
        msg.nick_style = this.getNickStyles(msg.nick).asCssString();

        // Generate a hex string from the nick to be used as a CSS class name
        nick_hex = '';
        if (msg.nick) {
            _.map(msg.nick.split(''), function (char) {
                nick_hex += char.charCodeAt(0).toString(16);
            });
            msg.css_classes += ' nick_' + nick_hex;
        }

        if (prev_msg) {
            // Time difference between this message and the last (in minutes)
            time_difference = (msg.time.getTime() - prev_msg.time.getTime())/1000/60;
            if (prev_msg.nick === msg.nick && time_difference < 1) {
                msg.css_classes += ' repeated_nick';
            }
        }

        // Build up and add the line
        if (_kiwi.global.settings.get('use_24_hour_timestamps')) {
            msg.time_string = msg.time.getHours().toString().lpad(2, "0") + ":" + msg.time.getMinutes().toString().lpad(2, "0") + ":" + msg.time.getSeconds().toString().lpad(2, "0");
        } else {
            hour = msg.time.getHours();
            pm = hour > 11;

            hour = hour % 12;
            if (hour === 0)
                hour = 12;

            am_pm_locale_key = pm ?
                'client_views_panel_timestamp_pm' :
                'client_views_panel_timestamp_am';

            msg.time_string = translateText(am_pm_locale_key, hour + ":" + msg.time.getMinutes().toString().lpad(2, "0") + ":" + msg.time.getSeconds().toString().lpad(2, "0"));
        }

        return msg;
    }
221037
function parser(msg, opts, cb) {
    let buffer = msg.payload;
    msg.payload = buffer.toString("ascii");
    cb(null, msg);
}
585025
function parsePostfixExpression() {
        var expr, token, startToken = lookahead;

        expr = inheritCoverGrammar(parseLeftHandSideExpressionAllowCall);

        if (!hasLineTerminator && lookahead.type === Token.Punctuator) {
            if (match('++') || match('--')) {
                // ECMA-262 11.3.1, 11.3.2
                if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
                    tolerateError(Messages.StrictLHSPostfix);
                }

                if (!isAssignmentTarget) {
                    tolerateError(Messages.InvalidLHSInAssignment);
                }

                isAssignmentTarget = isBindingElement = false;

                token = lex();
                expr = new WrappingNode(startToken).finishPostfixExpression(token.value, expr);
            }
        }

        return expr;
    }
1034685
function regExpBuilder (find) {
  const regExpRe = /\/(.*)\/(\w*)/
  if (find) {
    if (regExpRe.test(find)) {
      const matches = find.match(regExpRe)
      const pattern = matches[1]
      const flags = matches[2]
      return new RegExp(pattern, flags)
    } else {
      return find
    }
  } else {
    return null
  }
}
542061
function parse(src, module, makeModule, options) {
		// Find the first valid parser :
		debug('Find a parser for :', module.path)
		var result = _.find(parsers, function(def) {
			// debug('    Check parser match :', def.match)
			if(def.match instanceof RegExp) {
				return def.match.test(module.path);
			} else if ('string'   == typeof def.match) {
				return minimatch(module.path, def.match);
			} else if ('function' == typeof def.match) {
				return def.match(src, module, makeModule, options);
			} else {
				return false;
			}
		});
		if(!result) {
			debug('Warning: No valid parser found for %s. Json string is exported', module.path)
			return 'module.exports = ' + JSON.stringify(src);
		} else {
			debug('Ok parser match :', result.match);
			return result.parse(src, module, makeModule, options);
		}
	}
423513
def formatted_message( severity, msg )
      msg = String === msg ? msg : msg.inspect

      if args = _matched( msg )
        args.first.call msg, args.last
      elsif proc = configuration[:severities][severity]
        proc.call msg
      else
        msg
      end
    end
1325790
def _make_regex(self):
        
        rxp = "|".join(
            map(self._address_rxp, self.keys()),
        )
        self._regex = re.compile(
            rxp,
            re.IGNORECASE,
        )
317672
def regex_match_any(self, line, codes=None):
        """"""
        for selector in self.regex_selectors:
            for match in selector.regex.finditer(line):
                if codes and match.lastindex:
                    # Currently the group name must be 'codes'
                    try:
                        disabled_codes = match.group('codes')
                    except IndexError:
                        return True

                    disabled_codes = _stripped_codes(disabled_codes)

                    current_code = codes[-1]

                    if current_code in disabled_codes:
                        return True
                else:
                    return True
        return False
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