Package java.util.regex

Examples of java.util.regex.Pattern


     * @param uniqueName Unique name
     * @return Parsed unique name
     */
    public static List<String> parseUniqueName(String uniqueName) {
        List<String> trail = new ArrayList<String>();
        Pattern regex = Pattern.compile("([^\\[\\]\\.]*)");
        Matcher matcher = regex.matcher(uniqueName);
        while (matcher.find()) {
            String match = matcher.group();
            if (!match.equals("")) {
                trail.add(match);
            }
View Full Code Here


        prop.putHTML("filter", filter);
       
        // trying to compile the regular expression filter expression
        Matcher filterMatcher = null;
        try {
            final Pattern filterPattern = Pattern.compile(filter,Pattern.MULTILINE);
            filterMatcher = filterPattern.matcher("");
        } catch (final PatternSyntaxException e) {
            Log.logException(e);
        }

        int level = 0;
View Full Code Here

    this.server_port = server_port;
   
  }
 
  public ED2KServerLink(String link){
    Pattern s;
   
    Matcher m;
   
    s = Pattern.compile("ed2k:\\/\\/\\|server\\|([0-9]{1,3}+.[0-9]{1,3}+.[0-9]{1,3}+.[0-9]{1,3}+)\\|([0-65535]*)\\|\\/");
   
    m = s.matcher(link);
   
    if (m.matches()) {
      server_address = m.group(1);
      server_port = Integer.valueOf(m.group(2)).intValue();
    }
View Full Code Here

      server_port = Integer.valueOf(m.group(2)).intValue();
    }
  }
 
  public static boolean isValidLink(String link) {
    Pattern s;
   
    Matcher m;
   
    s = Pattern.compile("ed2k:\\/\\/\\|server\\|([0-9]{1,3}+.[0-9]{1,3}+.[0-9]{1,3}+.[0-9]{1,3}+)\\|([0-65535]*)\\|\\/");
   
    m = s.matcher(link);
   
    return m.matches();
  }
View Full Code Here

    return m.matches();
  }
 
  public static List<ED2KServerLink> extractLinks(String rawData) {
   
    Pattern s = Pattern.compile("ed2k:\\/\\/\\|server\\|([0-9]{1,3}+.[0-9]{1,3}+.[0-9]{1,3}+.[0-9]{1,3}+)\\|([0-65535]*)\\|\\/");
   
    Matcher m = s.matcher(rawData);
   
    List<ED2KServerLink> links = new LinkedList<ED2KServerLink>();
   
    while(m.find()) {
     
View Full Code Here

     * Splits at each sequence of non-word characters. <p/>Sequences of capitals
     * will be left untouched.
     */
    private static String[] splitAtNonWordCharacters(final String string)
    {
        final Pattern capitalSequencePattern = Pattern.compile("[A-Z]+");
        final Matcher matcher = capitalSequencePattern.matcher(StringUtils.trimToEmpty(string));
        final StringBuffer buffer = new StringBuffer();
        while (matcher.find())
        {
            matcher.appendReplacement(buffer, ' ' + matcher.group());
        }
View Full Code Here

      connection.addPostValue(VERSION_KEY, JMConstants.CURRENT_JMULE_VERSION);
      try {
        String result = connection.sendQuery();
        last_update_time = System.currentTimeMillis();
        response_code = connection.getHttpResponseCode();
        Pattern pattern = Pattern.compile(VERSION_REGEX);
        Matcher matcher = pattern.matcher(result);
        if (!matcher.find())
          throw new JMUpdaterException("Version tag not found");
        version = matcher.group(1);
        version = version.trim();
        result = result.replace("\n", "<br>");
        pattern = Pattern.compile(CHANGELOG_REGEX);
        matcher = pattern.matcher(result);
        if (!matcher.find())
          throw new JMUpdaterException("Changelog tag not found");
        changelog = matcher.group(1);
        changelog = changelog.replace("<br>", "\n");
        return ;
View Full Code Here

    public static String pluralize(String str)
    {

        for (Iterator i = uncountables.iterator(); i.hasNext();)
        {
            Pattern pattern = (Pattern)i.next();
            Matcher matcher = pattern.matcher(str);
            if (matcher.matches())
            {
                return str;
            }
        }

        List rules = FrenchInflector.getPluralRules();
        for (Iterator i = rules.iterator(); i.hasNext();)
        {
            Inflection inflection = (Inflection)i.next();
            Pattern pattern = inflection.getPattern();
            String replace = inflection.getReplace();
            Matcher matcher = pattern.matcher(str);
            if (matcher.matches())
            {
                return matcher.replaceFirst(replace);
            }
        }
View Full Code Here

  public ED2KFileLink(String fileLink) throws ED2KLinkMalformedException {
   
    if (!isValidLink(fileLink))
      throw new ED2KLinkMalformedException("This ED2K link is not valid " + fileLink);
   
    Pattern s;
    Matcher m;
    s = Pattern.compile(ED2K_LINK_PATTERN, Pattern.CASE_INSENSITIVE);
    m = s.matcher(fileLink);
    if (m.matches()) {
      this.fileName=m.group(1);
      this.fileSize=Long.valueOf(m.group(2)).longValue();
      this.fileHash = new FileHash(m.group(3));
      this.partHashSet = extractPartHashes(fileHash,m.group(4));
View Full Code Here

      this.sources = extractSources(m.group(6));
      }
  }
 
  public static List<ED2KFileLink> extractLinks(String rawData) throws ED2KLinkMalformedException {
    Pattern s;
    Matcher m;
    s = Pattern.compile(ED2K_LINK_PATTERN, Pattern.CASE_INSENSITIVE);
    m = s.matcher(rawData);
    List<ED2KFileLink> links = new LinkedList<ED2KFileLink>();
    while(m.find()) {
      String fileName = m.group(1);
      long fileSize = Long.valueOf(m.group(2)).longValue();
      FileHash fileHash = new FileHash(m.group(3));
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.