Package java.util.regex

Examples of java.util.regex.Matcher


        return new File(str);
    }

    private String uriDecode(String path) {
        StringBuffer builder = new StringBuffer();
        Matcher matcher = ENCODED_URI.matcher(path);
        while (matcher.find()) {
            String val = matcher.group(1);
            matcher.appendReplacement(builder, String.valueOf((char) (Integer.parseInt(val, 16))));
        }
        matcher.appendTail(builder);
        return builder.toString();
    }


        return null;
    }

    private static Pattern getPatternForName(String name) {
        Pattern boundaryPattern = Pattern.compile("((^|\\p{Punct})\\p{javaLowerCase}+)|(\\p{javaUpperCase}\\p{javaLowerCase}*)");
        Matcher matcher = boundaryPattern.matcher(name);
        int pos = 0;
        StringBuilder builder = new StringBuilder();
        while (matcher.find()) {
            String prefix = name.substring(pos, matcher.start());
            if (prefix.length() > 0) {
                builder.append(Pattern.quote(prefix));
            }
            builder.append(Pattern.quote(matcher.group()));
            builder.append("[\\p{javaLowerCase}\\p{Digit}]*");
            pos = matcher.end();
        }
        builder.append(Pattern.quote(name.substring(pos, name.length())));
        return Pattern.compile(builder.toString());
    }

    @Override
    protected TestDescriptorInternal convert(Object id, Test test) {
        if (test instanceof JUnit4TestCaseFacade) {
            JUnit4TestCaseFacade facade = (JUnit4TestCaseFacade) test;
            Matcher matcher = Pattern.compile("(.*)\\((.*)\\)").matcher(facade.toString());
            String className = facade.toString();
            String methodName = null;
            if (matcher.matches()) {
                className = matcher.group(2);
                methodName = matcher.group(1);
            }
            return new DefaultTestDescriptor(id, className, methodName);
        }
        // JUnit4TestCaseFacade is-a Describable in junit 4.7+
        if (test instanceof Describable) {

      ContentNetworkUtils.setSourceRef(tabID, sourceRef, false);

      if (MultipleDocumentInterface.SIDEBAR_SECTION_PLUS.equals(tabID) ||
          MultipleDocumentInterface.SIDEBAR_SECTION_BURN_INFO.equals(tabID)) {
        Pattern pattern = Pattern.compile("http.*//[^/]+/([^.]+)");
        Matcher matcher = pattern.matcher(sourceRef);
       
        String sourceRef2;
        if (matcher.find()) {
          sourceRef2 = matcher.group(1);
        } else {
          sourceRef2 = sourceRef;
        }
       
        if (MultipleDocumentInterface.SIDEBAR_SECTION_PLUS.equals(tabID)) {

        if (stringConstraint != null) {
            if (stringConstraint.required() & (object == null)) errors.add(new ValidationError(field.getName(), errorCodes[0], stringConstraint, object));
            if ((object != null) & (stringConstraint.regexp().length() > 0)) {
                try {
                    Pattern pattern = Pattern.compile(stringConstraint.regexp());
                    Matcher matcher = pattern.matcher(object.toString());
                    if (!matcher.matches()) errors.add(new ValidationError(field.getName(), errorCodes[1], stringConstraint, object));
                } catch (Exception ex) {
                    throw new ValidationException(ex);
                }
            }
            if ((object != null) & (stringConstraint.minLength() > 0)) {

   *           config string, format either widthxheight or
   *           widthxheight+xPos+yPos
   */
  private static void parseScreen( List<Screen> list, String name, String what )
  {
    Matcher m = SCREEN_PATTERN1.matcher( what );
    if( !m.matches() )
    {
      m = SCREEN_PATTERN2.matcher( what );
      if( !m.matches() )
      {
        LWJGLUtil.log( "Did not match: " + what );
        return;
      }
    }
    int width = Integer.parseInt( m.group( 1 ) );
    int height = Integer.parseInt( m.group( 2 ) );
    int xpos, ypos;
    if( m.groupCount() > 3 )
    {
      xpos = Integer.parseInt( m.group( 3 ) );
      ypos = Integer.parseInt( m.group( 4 ) );
    }
    else
    {
      xpos = 0;
      ypos = 0;

      return;
    }

    String url = dlInfo.getDownloadURL();
    try {
      Matcher m = hashPattern.matcher(url);
      if (m.find()) {
        String hash = m.group(1);
        GlobalManager gm = core.getGlobalManager();
        final DownloadManager dm = gm.getDownloadManager(new HashWrapper(
            Base32.decode(hash)));
        if (dm != null) {
          if (playNow || playPrepare) {

    if (value == null) {
      value = rb.getString(name, null);
    }

    if (expandReferences && value != null && value.indexOf('}') > 0) {
      Matcher matcher;

      if (params != null) {
        matcher = PAT_PARAM_NUM.matcher(value);
        while (matcher.find()) {
          String key = matcher.group(1);
          try {
            int i = Integer.parseInt(key);

            if (i < params.length) {
              value = value.replaceAll("\\Q{" + key + "}\\E", params[i]);
            } else {
              value = value.replaceAll("\\Q{" + key + "}\\E", "");
            }
          } catch (Exception e) {
          }
        }
      }

      matcher = PAT_PARAM_ALPHA.matcher(value);
      while (matcher.find()) {
        String key = matcher.group(1);
        String text = getValue(key, params);
        if (text == null) {
          text = MessageText.getString(key);
        }
        value = value.replaceAll("\\Q{" + key + "}\\E", text);

        s = removeValuesBetween("]", "[", s);
        s = removeValuesBetween("(", ")", s);
        s = removeValuesBetween("[", "]", s);

        for (int i = 0; i < normalizer.length; i++) {
            Matcher ma = normalizer[i].matcher(s);
            s = ma.replaceAll(" ");
        }
       
        s = s.replaceAll("\n", "");
        s = s.replaceAll("\r", "");
       

            }
           
            String regex = DcModules.get(getModule()).getSettings().getString(DcRepository.ModuleSettings.stTitleCleanupRegex);
            if (!Utilities.isEmpty(regex)) {
                Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
                Matcher matcher = pattern.matcher(name);
                while (matcher.find())
                    name = matcher.replaceAll("");
            }
        }
       
        return StringUtils.capitalize(name.trim());
    }   

TOP

Related Classes of java.util.regex.Matcher

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.