Package java.util.regex

Examples of java.util.regex.Pattern$Block


    // accept raw hash of 32 base-32 chars
    if (text.matches("^[a-zA-Z2-7]{32}$")) {
      return "magnet:?xt=urn:btih:" + text;
    }
   
    Pattern pattern;
    Matcher matcher;

    pattern = Pattern.compile("bc://bt/([a-z0-9=\\+/]+)", Pattern.CASE_INSENSITIVE);
    matcher = pattern.matcher(text.replaceAll(" ", "+"));
    if (matcher.find()) {
      String base64 = matcher.group(1);
      byte[] decode = Base64.decode(base64);
      if (decode != null && decode.length > 0) {
        // Format is AA/<name>/<size>/<hash>/ZZ
        try {
          String decodeString = new String(decode, "utf8");
          pattern = Pattern.compile("AA.*/(.*)/ZZ", Pattern.CASE_INSENSITIVE);
          matcher = pattern.matcher(decodeString);
          if (matcher.find()) {
            String hash = matcher.group(1);
            String magnet = parseTextForMagnets(hash);
            if (magnet != null) {
              pattern = Pattern.compile("AA/(.*)/[0-9]+", Pattern.CASE_INSENSITIVE);
              matcher = pattern.matcher(decodeString);
              if (matcher.find()) {
                String name = matcher.group(1);
                return magnet + "&dn=" + encode(name);
              }
              return magnet;
            }
          }
        } catch (UnsupportedEncodingException e) {
        }
      }
    }

    pattern = Pattern.compile("bctp://task/(.*)", Pattern.CASE_INSENSITIVE);
    matcher = pattern.matcher(text);
    if (matcher.find()) {
      // Format is <name>/<size>/<hash>
      String decodeString = matcher.group(1);
      String magnet = parseTextForMagnets(decodeString);
      if (magnet != null) {
        pattern = Pattern.compile("(.*)/[0-9]+", Pattern.CASE_INSENSITIVE);
        matcher = pattern.matcher(decodeString);
        if (matcher.find()) {
          String name = matcher.group(1);
          return magnet + "&dn=" + encode(name);
        }
        return magnet;
      }
    }

    // accept raw hash of 32 base-32 chars, with garbage around it
    if (true) {
      text = "!" + text + "!";
      pattern = Pattern.compile("[^a-zA-Z2-7][a-zA-Z2-7]{32}[^a-zA-Z2-7]");
      matcher = pattern.matcher(text);
      if (matcher.find()) {
        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


        while (thisIndexIterator.hasNext()) {
          int currentIndex = ((Integer) thisIndexIterator.next()).intValue();
          String fieldValue = String.valueOf(rowData.get(currentIndex - 1));

          if (fieldValue != null) {
            Pattern pattern = Pattern.compile("[^a-zA-z_0-9 ]");
            Matcher fieldMatch = pattern.matcher(fieldValue);
            fieldValue = fieldMatch.replaceAll("");
            // fieldValue = fieldValue.replaceAll("'","");
          }

          if (fieldValue == null || fieldValue.equals("null")) {
View Full Code Here

          }
        }

        String s = bRegexSearch ? tmpSearch : "\\Q"
            + tmpSearch.replaceAll("[|;]", "\\\\E|\\\\Q") + "\\E";
        Pattern pattern = Pattern.compile(s, Pattern.CASE_INSENSITIVE);

        if (!pattern.matcher(name).find())
          bOurs = false;
      } catch (Exception e) {
        // Future: report PatternSyntaxException message to user.
      }
    }
View Full Code Here

      "/etc/gre.d/libxul0d.conf"
    };

    log("Auto-scanning for GRE/XULRunner.  You can skip this by appending the GRE path to LD_LIBRARY_PATH and setting MOZILLA_FIVE_HOME.");
    try {
      Pattern pat = Pattern.compile("GRE_PATH=(.*)", Pattern.CASE_INSENSITIVE);
      for (int i = 0; i < confList.length; i++) {
        File file = new File(confList[i]);
        if (file.isFile() && file.canRead()) {
          log("  checking " + file + " for GRE_PATH");
          String fileText = FileUtil.readFileAsString(file, 16384);
          if (fileText != null) {
            Matcher matcher = pat.matcher(fileText);
            if (matcher.find()) {
              String possibleGrePath = matcher.group(1);
              if (isValidGrePath(new File(possibleGrePath))) {
                grePath = possibleGrePath;
                break;
View Full Code Here

   * @param f
   * @return
   */
  public static boolean mkdirs(File f) {
    if (Constants.isOSX) {
      Pattern pat = Pattern.compile("^(/Volumes/[^/]+)");
      Matcher matcher = pat.matcher(f.getParent());
      if (matcher.find()) {
        String sVolume = matcher.group();
        File fVolume = new File(sVolume);
        if (!fVolume.isDirectory()) {
          Logger.log(new LogEvent(LOGID, LogEvent.LT_WARNING, sVolume
View Full Code Here

    } else return entityHeight;
  }

  @Override
  public AlmostBoolean isBlockSolid(final int id) {
    final Block block = Block.byId[id];
    if (block == null || block.material == null) return AlmostBoolean.MAYBE;
    else return AlmostBoolean.match(block.material.isSolid());
  }
View Full Code Here

    else return AlmostBoolean.match(block.material.isSolid());
  }

  @Override
  public AlmostBoolean isBlockLiquid(final int id) {
    final Block block = Block.byId[id];
    if (block == null || block.material == null) return AlmostBoolean.MAYBE;
    else return AlmostBoolean.match(block.material.isLiquid());
  }
View Full Code Here

    } else return entityHeight;
  }

  @Override
  public AlmostBoolean isBlockSolid(final int id) {
    final Block block = Block.byId[id];
    if (block == null || block.material == null) return AlmostBoolean.MAYBE;
    else return AlmostBoolean.match(block.material.isSolid());
  }
View Full Code Here

    else return AlmostBoolean.match(block.material.isSolid());
  }

  @Override
  public AlmostBoolean isBlockLiquid(final int id) {
    final Block block = Block.byId[id];
    if (block == null || block.material == null) return AlmostBoolean.MAYBE;
    else return AlmostBoolean.match(block.material.isLiquid());
  }
View Full Code Here

    } else return entityHeight;
  }

  @Override
  public AlmostBoolean isBlockSolid(final int id) {
    final Block block = Block.byId[id];
    if (block == null || block.material == null) return AlmostBoolean.MAYBE;
    else return AlmostBoolean.match(block.material.isSolid());
  }
View Full Code Here

TOP

Related Classes of java.util.regex.Pattern$Block

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.