Package java.util.regex

Examples of java.util.regex.Pattern.matcher()


        String hash = text.substring(matcher.start() + 1, matcher.start() + 33);
        return "magnet:?xt=urn:btih:" + hash;
      }

      pattern = Pattern.compile("[^a-fA-F0-9][a-fA-F0-9]{40}[^a-fA-F0-9]");
      matcher = pattern.matcher(text);
      if (matcher.find()) {
        String hash = text.substring(matcher.start() + 1, matcher.start() + 41);
        // convert from HEX to raw bytes
        byte[] infohash = ByteFormatter.decodeString(hash.toUpperCase());
        // convert to BASE32
View Full Code Here


    // <A style=cow HREF="http://abc.om/moo">test</a>
    // <a href="http://www.gnu.org/licenses/fdl.html" target="_top">moo</a>

    Pattern pat = Pattern.compile("<.*a\\s++.*href=\"?([^\\'\"\\s>]++).*",
        Pattern.CASE_INSENSITIVE);
    Matcher m = pat.matcher(text);
    if (m.find()) {
      String sURL = m.group(1);
      try {
        sURL = URLDecoder.decode(sURL);
      } catch (Exception e) {
View Full Code Here

          String startIp = null;
          String endIp = null;
          int level = 0;

          if (parseMode <= 0 || parseMode == 1) {
            Matcher matcher = pattern.matcher(line);
            if (matcher.find()) {
              if (parseMode != 1) {
                parseMode = 1;
              }
              description = matcher.group(1);
View Full Code Here

   {
      //jdbc:hsqldb:mem:jbosscache
      Properties toReturn = (Properties) realProps.clone();
      String jdbcUrl = toReturn.getProperty("cache.jdbc.url");
      Pattern pattern = Pattern.compile("jbosscache");
      Matcher matcher = pattern.matcher(jdbcUrl);
      boolean found = matcher.find();
      assert found;
      String newJdbcUrl = matcher.replaceFirst(extractTestName() + userIndex.incrementAndGet());
      toReturn.put("cache.jdbc.url", newJdbcUrl);
      return toReturn;
View Full Code Here

                parentFile = new File(folder);
            }
            parentFile.mkdirs();
            Pattern p = Pattern.compile("class ([a-zA-Z0-9]+)");
            for (String model : models) {
                Matcher m = p.matcher(model);
                if (m.find()) {
                    String className = m.group().substring("class".length()).trim();
                    File classFile = new File(parentFile, className + ".java");
                    Writer o = new FileWriter(classFile, false);
                    PrintWriter writer = new PrintWriter(new BufferedWriter(o));
View Full Code Here

            return true;
        }
        Pattern literalDefault = Pattern.compile("'.*'");
        Pattern functionDefault = Pattern.compile("[^'].*[^']");
        return literalDefault.matcher(defaultValue).matches()
            || functionDefault.matcher(defaultValue).matches();
    }

    /**
     * Checks to see if the default value matches the class.
     *
 
View Full Code Here

        // MySQL does not single-quote literal values so its hard to
        // differentiate a FUNCTION/VARIABLE from a literal value.

        // function / variable
        Pattern functionDefault = Pattern.compile("[^'].*[^']");
        if (functionDefault.matcher(defaultValue).matches()) {
            // hard to validate this since its in the database
            // assume it is good
            return true;
        }

View Full Code Here

        }

        // STRING
        if (modelClass == String.class) {
            Pattern stringDefault = Pattern.compile("'(.|\\n)*'");
            return stringDefault.matcher(defaultValue).matches();
        }

        String dateRegex = "[0-9]{1,4}[-/\\.][0-9]{1,2}[-/\\.][0-9]{1,2}";
        String timeRegex = "[0-2]{1}[0-9]{1}:[0-5]{1}[0-9]{1}:[0-5]{1}[0-9]{1}";

View Full Code Here

            // this may be a little loose....
            // 00-00-00 00:00:00
            // 00/00/00T00:00:00
            // 00.00.00T00:00:00
            Pattern pattern = Pattern.compile("'" + dateRegex + "." + timeRegex + "'");
            return pattern.matcher(defaultValue).matches();
        }

        // DATE
        if (modelClass == java.sql.Date.class) {
            // this may be a little loose....
View Full Code Here

            // this may be a little loose....
            // 00-00-00
            // 00/00/00
            // 00.00.00
            Pattern pattern = Pattern.compile("'" + dateRegex + "'");
            return pattern.matcher(defaultValue).matches();
        }

        // TIME
        if (modelClass == java.sql.Time.class) {
            // 00:00:00
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.