Package java.util.regex

Examples of java.util.regex.Pattern


          throw new RuntimeException();
        } else {
          regex = patterns.get(patternName).getRegex();
        }
      }
      Pattern pattern = (regex == null) ? null : Pattern.compile(regex);

      EnumSet<AttributeValidator.Flag> flags =
          EnumSet.noneOf(AttributeValidator.Flag.class);
      if (flagNames != null) {
        for (String flagName : split(flagNames)) {
View Full Code Here


            ImageIcon statusIcon = null;

            // name based guess
            if (buddy.getUser().indexOf("@") == -1) {
                Pattern p = Pattern
                        .compile("^(aim|msn|yahoo|icq|gadu-gadu)[-_.].*");
                Matcher m = p.matcher(buddy.getUser());
                if (m.matches() && m.groupCount() >= 1) {
                    String type = m.group(1);
                    if (type != null) {
                        statusIcon = Standard
                                .getIcon("imagethemes/statusicons/"
View Full Code Here

      String name = getVariableName(attrMap, "name", false);
      List<JavaAnnotation> javaAnnotations
          = getJavaAnnotations(node, JavaAnnotation.Element.PARAM);
      Expression defaultValue = null;
      boolean hasDefaultFlag = false;
      Pattern regex = null;
      Expression constructor = null;
      boolean hasConstructorFlag = false;

      String content = attrMap.getOptional("content", null);
      Type defaultType = null;
View Full Code Here

  }
 
  public static class JavaSourceFileMethodParametersParser {

        public String[] parseJavaFileForParamNames(Method method,String content) {
            Pattern methodPattern = Pattern.compile("(?s)"+method.getName()+"\\s*\\("+getParamsPattern(method)+"\\)\\s*\\{");
          Matcher m = methodPattern.matcher(content);
          List paramNames = new ArrayList();
          while(m.find()) {
              for(int i = 1; i <= method.getParameterTypes().length; i++) {
                    paramNames.add(m.group(i));
                }
View Full Code Here

        }
       
        String javaSourceContent = removeSomeThings();
        String methodBody = getMethodBody(javaSourceContent);
       
        Pattern p = Pattern.compile(fieldMethodInvokeRegex);
        Matcher m = p.matcher(methodBody);
        while(m.find()) {
          String field = m.group(1);
          String methodName= m.group(2);
          addFieldMethodInvocation(field, methodName);
        }
View Full Code Here

  public void test_insertBefore() {
      assertEquals("1 2 3 \n 4 abc5 6",StringHelper.insertBefore("1 2 3 \n 4 5 6", "5", "abc"));
  }
 
  public void test_appendReplacement() {
    Pattern p = Pattern.compile("(\\d+)(\\w+)");
    Matcher m = p.matcher("jjj123www");
    m.find();
    StringBuffer sb = new StringBuffer();
    m.appendReplacement(sb, "|$2|");
    assertEquals("jjj|www|",sb.toString());
  }
View Full Code Here

    m.appendReplacement(sb, "|$2|");
    assertEquals("jjj|www|",sb.toString());
  }

  public void test_appendReplacement_with_escape_doler_char() {
    Pattern p = Pattern.compile("(\\d+)(\\w+)");
    Matcher m = p.matcher("jjj123www");
    m.find();
    StringBuffer sb = new StringBuffer();
    StringHelper.appendReplacement(m,sb, "|$2|");
    assertEquals("jjj|$2|",sb.toString());
  }
View Full Code Here

    /* Look if Encoding is supplied */
    if (firstLine.indexOf("encoding") >= 0) { //$NON-NLS-1$

      /* Extract the Encoding Value */
      String regEx = "<\\?.*encoding=[\"']([^\\s]*)[\"'].*\\?>"; //$NON-NLS-1$
      Pattern pattern = Pattern.compile(regEx);
      Matcher match = pattern.matcher(firstLine);

      /* Get first matching String */
      if (match.find())
        return match.group(1);
    }
View Full Code Here

    if (!titleFound)
      return title;

    /* Extract the title String */
    String regEx = "<title[^>]*>[^<]*</title>"; //$NON-NLS-1$
    Pattern pattern = Pattern.compile(regEx);
    Matcher match = pattern.matcher(title);

    /* Get first matching String */
    if (match.find())
      title = match.group();

View Full Code Here

  * @param entityTypes A list of entity types
  * @return Regex pattern for the entity types
  */
public static Pattern getCollapsePattern(String[] entityTypes)
{
  Pattern collapsePattern = null;
  StringBuffer collapseStr = new StringBuffer();
  for (int i = 0; i < entityTypes.length; i++)
  { collapseStr.append( "(<\\/"); collapseStr.append(entityTypes[i]); collapseStr.append(">\\s+");
  collapseStr.append("<"); collapseStr.append(entityTypes[i]); collapseStr.append(">)|");
  }
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.