Package java.util.regex

Examples of java.util.regex.Pattern


      "/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

   * @param filter wildcard (glob) filter
   * @return list of matched DownloadManager objects
   */
  private List matchWildcard( List torrents, String filter )
  {
    Pattern pattern = Pattern.compile(wildcardToPattern(filter), Pattern.CASE_INSENSITIVE);
    List list = new ArrayList();
    for (Iterator iter = torrents.iterator(); iter.hasNext();) {
      DownloadManager dm = (DownloadManager) iter.next();
      if( pattern.matcher(dm.getDisplayName()).matches() )
        list.add(dm);
    }
    return list;
  }
View Full Code Here

    try {
      version = Integer.parseInt(sVersion);
    } catch (Throwable t) {
    }
   
    Pattern pat = Pattern.compile("SCRIPT_VERSION=([0-9]+)",
        Pattern.CASE_INSENSITIVE);
   
   
    File oldFilePath;
    String sScriptFile = System.getProperty("azureus.script", null);
    if (sScriptFile != null && new File(sScriptFile).exists()) {
      oldFilePath = new File(sScriptFile);
    } else {
      oldFilePath = new File(SystemProperties.getApplicationPath(),
          "azureus");
      if (!oldFilePath.exists()) {
        return;
      }
    }

    final String oldFilePathString = oldFilePath.getAbsolutePath();

    String oldStartupScript;
    try {
      oldStartupScript = FileUtil.readFileAsString(oldFilePath,
          65535, "utf8");
    } catch (IOException e) {
      oldStartupScript = "";
    }

    // Case: Script with no version, we update it, user selects restart.
    //       Restart doesn't include azureus.script.version yet, so we
    //       would normally prompt again.  This fix reads the version
    //       from the file if we don't have a version yet, thus preventing
    //       the second restart message
    if (version == 0) {
      Matcher matcher = pat.matcher(oldStartupScript);
      if (matcher.find()) {
        String sScriptVersion = matcher.group(1);
        try {
          version = Integer.parseInt(sScriptVersion);
        } catch (Throwable t) {
        }
      }
    }
   
    if (version <= lastAskedVersion) {
      return;
    }

    InputStream stream = getClass().getResourceAsStream("startupScript");
    try {
      String startupScript = FileUtil.readInputStreamAsString(stream, 65535,
          "utf8");
      Matcher matcher = pat.matcher(startupScript);
      if (matcher.find()) {
        String sScriptVersion = matcher.group(1);
        int latestVersion = 0;
        try {
          latestVersion = Integer.parseInt(sScriptVersion);
View Full Code Here

    // examples:
    // <A HREF=http://abc.om/moo>test</a>
    // <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

      List new_ipRanges = new ArrayList(1024);

      InputStreamReader streamReader = null;
      BufferedReader reader = null;
      try {
        Pattern pattern = Pattern.compile("^(.*):([0-9\\.]+)[^0-9]+([0-9\\.]+).*");
        int parseMode = -1;

        //open the file
        // TODO: test charset fallback (should fallback to ascii)
        streamReader = new InputStreamReader(fin, "utf8");
        reader = new BufferedReader(streamReader);

        int numConsecutiveUnknowns = 0;

        while (numConsecutiveUnknowns < 1000) {
          String line = reader.readLine();
          //System.out.println("line=" + line);
          if (line == null) {
            break;
          }

          line = line.trim();

          if (line.startsWith("#") || line.length() == 0) {
            continue;
          }

          String description = "";
          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

    // fill color is handled after we return
    return ret;
  }
 
  private static List<Location> parsePoints(String points) {
    Pattern patt = Pattern.compile("[ ,\n\r\t]+");
    String[] toks = patt.split(points);
    Location[] ret = new Location[toks.length / 2];
    for (int i = 0; i < ret.length; i++) {
      int x = Integer.parseInt(toks[2 * i]);
      int y = Integer.parseInt(toks[2 * i + 1]);
      ret[i] = Location.create(x, y);
View Full Code Here

   private static Properties returnBasedOnDifferentInstance()
   {
      //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(System.getProperty("user.dir"));
            } else {
                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

     */
    static boolean isProperlyFormattedDefaultValue(String defaultValue) {
        if (isNullOrEmpty(defaultValue)) {
            return true;
        }
        Pattern literalDefault = Pattern.compile("'.*'");
        Pattern functionDefault = Pattern.compile("[^'].*[^']");
        return literalDefault.matcher(defaultValue).matches()
            || functionDefault.matcher(defaultValue).matches();
    }
View Full Code Here

TOP

Related Classes of java.util.regex.Pattern

Copyright © 2015 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.