Package java.util.regex

Examples of java.util.regex.Pattern


    }
    return links;
  }
 
  public static boolean isValidLink(String link) {
    Pattern s;
    Matcher m;
    s = Pattern.compile(ED2K_LINK_PATTERN, Pattern.CASE_INSENSITIVE);
    m = s.matcher(link);
    return m.matches();
  }
View Full Code Here


 
  private static PartHashSet extractPartHashes(FileHash fileHash, String partHashsRawData) {
    PartHashSet partHashSet = null;
    if (partHashsRawData != null) {
      partHashSet = new PartHashSet(fileHash);
      Pattern p = Pattern.compile(":");
      String[] partHashArray = p.split(partHashsRawData);
      for(String partHash : partHashArray)
        partHashSet.add(Convert.hexStringToByte(partHash));
    }
    return partHashSet;
  }
View Full Code Here

  }

  private static List<URL> extractUrls(String linkRawData) throws ED2KLinkMalformedException {
    List<URL> urls = new ArrayList<URL>();
    if (linkRawData != null) {
      Pattern s = Pattern.compile(URL_PATTERN, Pattern.CASE_INSENSITIVE);
      Matcher m = s.matcher(linkRawData);
      while (m.find()) {
        try {
          urls.add(new URL(m.group(1)));
        } catch (MalformedURLException e) {
          throw new ED2KLinkMalformedException(e);
View Full Code Here

  }

  private static List<InetSocketAddress> extractSources(String sourcesRawData) {
    List<InetSocketAddress> sources = new ArrayList<InetSocketAddress>();
    if (sourcesRawData != null) {
      Pattern s = Pattern.compile(SOURCES_PATTERN, Pattern.CASE_INSENSITIVE);
      Matcher m = s.matcher(sourcesRawData);
      while (m.find()) {
        String hostName = m.group(1);
        int port = Integer.parseInt(m.group(2));
        sources.add(InetSocketAddress.createUnresolved(hostName, port));
      }
View Full Code Here

     * @param kind       the constraint kind (i.e. <em>inv</em>,<em>pre</em>, <em>body</em>, etc).
     * @return true/false
     */
    public static boolean isConstraintKind(String expression, String kind)
    {
        Pattern pattern = Pattern.compile(".*\\s*" + StringUtils.trimToEmpty(kind) + "\\s*\\w*\\s*:.*", Pattern.DOTALL);
        Matcher matcher = pattern.matcher(StringUtils.trimToEmpty(expression));
        return matcher.matches();
    }
View Full Code Here

   
    Set<String>  expanded = new HashSet<String>();

    for(String type : types) { 
     
      Pattern pattern = Pattern.compile( type );
           
      for(String s : _ST_ALL) { 
       
        if ( pattern.matcher( s ).matches()){

          expanded.add( s );
        }
      }
    }
View Full Code Here

//    private String catalogFilenameSubstitutionPattern;
//    private boolean expand = true;
//    private boolean flattenCatalog = false;

    //Pattern p = Pattern.compile("/(eta_[0-9]*)/$"); // doesn't match
    Pattern p = Pattern.compile(".*/(eta_[0-9]*)/$"); // matches
    Matcher m = p.matcher("fred/the/eta_211/");
    //boolean b = m.matches();
    if ( m.matches())
    {
      System.out.println( "Matches" );
      System.out.println( "numGroups : " + m.groupCount());
View Full Code Here

  public static String getCDATASection(String domArgument)
  {
    if (!domArgument.contains("CDATA"))
      return null;
    Pattern pat = Pattern.compile("(.*)\\<\\!(\\s*)\\[CDATA(.*)\\]\\]\\>(.*)", Pattern.DOTALL + Pattern.MULTILINE);
    Matcher mat = pat.matcher(domArgument);
    if (mat.find())
    {
      String group3 = mat.group(3);
      if (group3.startsWith("["))
        group3 = group3.replaceFirst("\\[", "");
View Full Code Here

   *        the location of a repository implementing this REST protocol.
   * @return the base location of a server implementing this REST protocol.
   */
  public static final String getServerLocation(String repositoryLocation) {
    // Try to parse the server URL from the repository URL
    Pattern urlPattern = Pattern.compile("(.*)/" + Protocol.REPOSITORIES + "/[^/]*/?");
    Matcher matcher = urlPattern.matcher(repositoryLocation);

    if (matcher.matches() && matcher.groupCount() == 1) {
      return matcher.group(1);
    }
    else {
View Full Code Here

        if (param == null) {  // try the regex list
            Set<String> keys = templateParamMap.keySet();
            if ( !keys.isEmpty()) {
                for (Iterator iter = keys.iterator(); iter.hasNext(); ) {
                    String  key = (String) iter.next();
                    Pattern p   = Pattern.compile(key);
                    Matcher m   = p.matcher(name);
                    if (m.matches()) {
                        //System.out.println("found match " + key + " for " + name);
                        String value = m.group(1);
                        GempakParameter match =
                            (GempakParameter) templateParamMap.get(key);
View Full Code Here

TOP

Related Classes of java.util.regex.Pattern

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.