Package java.util.regex

Examples of java.util.regex.Matcher


        }
        return result;
    }

    private int classify(String string) {
        Matcher m = keyword.matcher(string);
        if (!m.matches())
            return OTHER;
        for (int i = 1; i <= m.groupCount(); i++)
            if (m.start(i) != -1)
                return i;
        throw new IllegalStateException(
                "IRI code internal error: no group matched.");
    }


                  handleGeneric( client_address, "motorola", "Motorola DLNA" );

                  handled = true;

                }else if ( lc_agent.contains( "sec_hhp")) {
                  Matcher match = Pattern.compile("SEC_HHP_(.*)/").matcher(user_agent);
                  if (match.find()) {
                    String name = match.group(1);
                    handleGeneric(client_address, "SEC_HPP_" + name, name);
                    handled = true;
                  }

                }

        if ((stringField != null) & (req.regexp().length() > 0))
        {
            try
            {
                Pattern pattern = Pattern.compile(req.regexp());
                Matcher matcher = pattern.matcher(stringField);
                if (!matcher.matches())
                    errors.rejectValue(field.getName(), errorCodes[1], req.regexp());
            }
            catch (Exception ex)
            {
                if (log.isDebugEnabled()) log.debug("Error validating " + field, ex);

  modifyDeviceDisplayName(
    String    name )
  {
    for ( Pattern p: device_renames ){
   
      Matcher m = p.matcher( name );
   
      if ( m.find()){
     
        String  new_name = m.group(1);
               
        return( new_name );
      }
    }
 

    }

    public static boolean matchPattern(String fileName, String regex) {
        if (regex == null) return true;
        Pattern p = Pattern.compile(regex);
        Matcher m = p.matcher(fileName);
        return m.matches();
    }

    });

    JSAPResult jsapResult = jsap.parse( arg );
    if ( jsap.messagePrinted() ) return;
    Pattern pattern = Pattern.compile( "\t" );
    Matcher matcher = pattern.matcher( "" );
   
    final int h = jsapResult.getInt( "h" );
    final String basename = jsapResult.getString( "basename" );
    final PrintStream printStream[] = new PrintStream[ h + 1 ];
    for( int i = 0; i <= h; i++ ) printStream[ i ] = new PrintStream( new FastBufferedOutputStream( new FileOutputStream( basename + "-" + i + DiskBasedIndex.STATS_EXTENSION ) ) );
   
    final MutableString line = new MutableString();
    final FastBufferedReader reader = new FastBufferedReader( new InputStreamReader( System.in ) );
   
    int l, start;
    while( reader.readLine( line ) != null ) {
      if ( line.charAt( 0 ) == '#' ) continue;
      matcher.reset( line );
      l = 0;
      start = 0;
      while( matcher.find() && l <= h ) {
        printStream[ l ].println( line.subSequence( start, matcher.start() ) );
        start = matcher.end();
        l++;
      }
    }
   
    for( int i = 0; i <= h; i++ ) printStream[ i ].close();

    if (reference !=null)
    {
      last_channels = (HashMap)reference.get();
    }

    Matcher detect_matcher = DETECT.matcher(fullMessage.getTrailing());
    if (detect_matcher.matches())
    {
      if (null == last_channels)
      {
        return;
      }
     
      String last_log = (String)last_channels.get(channel.getName());
      if (null == last_log)
      {
        return;
      }
         
      try
      {
        Pattern log_pattern = Pattern.compile(detect_matcher.group(1));
        Matcher log_matcher = log_pattern.matcher(last_log);
        String result = null;
        if ("g".equals(detect_matcher.group(3)))
        {
          result = log_matcher.replaceAll(detect_matcher.group(2));
        }
        else
        {
          result = log_matcher.replaceFirst(detect_matcher.group(2));
        }

        if (!last_log.equals(result))
        {
          if (result.length() > 120)

      {
        bot.send(new Privmsg(nick, "You need to provide an argument to the command."));
        return;
      }
     
      Matcher seen_matcher = DO_PATTERN.matcher(arguments);
     
      if (!seen_matcher.matches() ||
        seen_matcher.groupCount() != 2)
      {
        bot.send(new Privmsg(nick, "Invalid syntax '" + command + " " + arguments + "'"));
        return;
      }
     
      // obtain the requested channel
      String channel_name = seen_matcher.group(1).toLowerCase();
      String message = seen_matcher.group(2);
      Channel  channel = bot.getServer().getChannel(channel_name);
      if (null == channel)
      {
        return;
      }

        if ((stringField != null) & (req.regexp().length() > 0))
        {
            try
            {
                Pattern pattern = Pattern.compile(req.regexp());
                Matcher matcher = pattern.matcher(stringField);
                if (!matcher.matches())
                    errors.rejectValue(field.getName(), errorCodes[1], req.regexp());
            }
            catch (Exception ex)
            {
                if (log.isDebugEnabled()) log.debug("Error validating " + field, ex);

   
    String output = null;
    if(input != null) {
      for(int i = 0 ; i < fieldRemappings.length ; i++) {
        if(fieldRemappings[i].getMatch() != null && fieldRemappings[i].getReplacement() != null) {
          Matcher matcher = fieldRemappings[i].getMatch().matcher(input);
          if(matcher.matches()) {
            output = matcher.replaceAll(fieldRemappings[i].getReplacement());
            i = fieldRemappings.length;
          }
        }
      }
    }

TOP

Related Classes of java.util.regex.Matcher

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.