Package java.util.regex

Examples of java.util.regex.Pattern$LineEnding


    String regex = this.value;
    regex = regex.replaceAll("\\\\c","[\\\\w.:-]");
    regex = regex.replaceAll("\\\\C","[^\\\\w.:-]");
    regex = regex.replaceAll("\\\\i","[\\\\p{Alpha}:_]");
    regex = regex.replaceAll("\\\\I","[^\\\\p{Alpha}:_]");
    Pattern p = Pattern.compile(regex);
    boolean valid = p.matcher(value).matches();
    return valid;
  }
View Full Code Here


      if (ym!=null) object.addProperty(RDF.value, ym);
      if (dt!=null) object.addProperty(RDF.value, dt);
    }
    else if (type.endsWith("#ENTITY")) {
      DocumentType doctype = elem.getOwnerDocument().getDoctype();
      Pattern entityPattern = Pattern.compile("<!ENTITY\\s+"+value+"\\s+'(.*)'>");
      Matcher match = entityPattern.matcher(doctype.getInternalSubset());
      if (match.find()) value = match.group(1);
      Literal l = m.createTypedLiteral(value,RDF.getURI()+"XMLLiteral");
      stmt = m.createStatement(subject,prop,l);
    }
    else { // schema datatype?
View Full Code Here

   * @return a new string with the matching star-enclosed text replaced.
   */
  public static String highlightStarEnclosedText(String text, String pre, String post){
    try{
      String srcText = text;
      Pattern p = Pattern.compile("(.*)\\*(\\S+)\\*(.*)");
      Matcher m = p.matcher(text);
      while(m.matches()){
        srcText = m.replaceFirst("$1" + pre+"$2"+post + "$3");
        m = p.matcher(srcText);
      }
      return srcText;
    }catch(Exception e){
     
    }
View Full Code Here

    }

    if (QueryEvaluationUtil.isSimpleLiteral(arg) && QueryEvaluationUtil.isSimpleLiteral(parg)
        && (farg == null || QueryEvaluationUtil.isSimpleLiteral(farg)))
    {
      Pattern pattern = node.compile(parg, farg);
      if (pattern == null) {
        throw new ValueExprEvaluationException();
      }
      boolean result = pattern.matcher(arg.stringValue()).find();
      return BooleanLiteralImpl.valueOf(result);
    }

    throw new ValueExprEvaluationException();
  }
View Full Code Here

  private void initialize(String pattern) {
    if (pattern == null || pattern.trim().length() == 0) {
      sections.add(new Section());
    } else {
      pattern = pattern.trim().replaceAll("\\\\", "/");
      Pattern p = Pattern.compile("\\A(([a-zA-Z]:)?/)");
      Matcher matcher = p.matcher(pattern);
      // Look if we've got a absolute or a relativ path
      boolean startsWithSysRoot = matcher.lookingAt();
      if (startsWithSysRoot) {
        sections.add(new Section(pattern
            .substring(0, matcher.end() - 1)));
View Full Code Here

  //   x is a label for an item and y is the index in bibliography

  public final boolean parseAuxFile(String filename)
  {
    // regular expressions
    Pattern pattern ;
    Matcher matcher ;

    // while condition
    boolean weiter = false ;

    // return value -> default: no error
    boolean back = true ;

    // fileopen status
    boolean loopFileOpen = false ;

    // the important tag
    pattern = Pattern.compile( "\\\\citation\\{.+\\}" ) ;

    // input-file-buffer
    BufferedReader br = null ;

    // filelist, used for nested aux files
    Vector<String> fileList = new Vector<String>(5) ;
    fileList.add( filename );

    // get the file path
    File dummy = new File( filename ) ;
    String path = dummy.getParent() ;
    if (path != null)
      path = path + File.separator ;
    else
      path = "" ;

    nestedAuxCounter = -1 // count only the nested reads

    // index of current file in list
    int fileIndex = 0 ;

    while (fileIndex < fileList.size())
    {
      String fName = fileList.elementAt( fileIndex ) ;
      try
      {
//        System.out.println("read #"+fName +"#") ;
        br = new BufferedReader( new FileReader( fName ) ) ;
        weiter = true ;
        loopFileOpen = true ;
      }
      catch ( FileNotFoundException fnfe )
      {
        System.out.println( "Cannot locate input file! " + fnfe.getMessage() ) ;
        // System.exit( 0 ) ;
        back = false ;
        weiter = false ;
        loopFileOpen = false ;
      }

      while ( weiter )
      {
        String line ;
        try
        {
            if (br == null)
                throw new IOException();
            line = br.readLine() ;
        }
        catch ( IOException ioe )
        {
          line = null ;
          weiter = false ;
        }

        if ( line != null )
        {
          matcher = pattern.matcher( line ) ;

          while ( matcher.find() )
          {
            // extract the bibtex-key(s) XXX from \citation{XXX} string
            int len = matcher.end() - matcher.start() ;
View Full Code Here

          }
          // We already did the currentDirectory
          return null;
        }

        final Pattern toMatch = Pattern
          .compile(dirToProcess.replaceAll("\\\\\\\\", "\\\\"));

        File[] matches = directory.listFiles(new FilenameFilter() {
          public boolean accept(File arg0, String arg1) {
            return toMatch.matcher(arg1).matches();
          }
        });
        if (matches == null || matches.length == 0)
          return null;

        directory = matches[0];

        if (!directory.exists())
          return null;

      } // End process directory information
    }
    // Last step check if the given file can be found in this directory
    String filenameToLookFor = expandBrackets(fileParts[fileParts.length - 1], entry, database);

    final Pattern toMatch = Pattern.compile("^"
      + filenameToLookFor.replaceAll("\\\\\\\\", "\\\\") + "$");

    File[] matches = directory.listFiles(new FilenameFilter() {
      public boolean accept(File arg0, String arg1) {
        return toMatch.matcher(arg1).matches();
      }
    });
    if (matches == null || matches.length == 0)
      return null;
View Full Code Here

   }

   private String getTableFromSQLIntern(String sql)
   {
      
      Pattern patternBeforeTable = Pattern.compile("SELECT\\s+[A-Z0-9_\\*\\.',\\s]*\\s+FROM\\s+([A-Z0-9_\\.]+)");
      sql = sql.toUpperCase().trim();
      // Bug 1371587 - remove useless accent characters if they exist
      sql = sql.replaceAll("\\`", "");
      Matcher matcher;

      matcher = patternBeforeTable.matcher(sql);
      if(false == matcher.find())
      {
         return null;
      }
      String table = matcher.group(1);
      String behindTable = sql.substring(matcher.end(1)).trim();

      int ret = behindTableAllowsEditing(behindTable);

      if(ALLOWS_EDITING_UNKNOWN == ret)
      {
         // This might be because an table alias is used maybe with an AS before it.

         Pattern patternBehindTable;
         if(behindTable.startsWith("AS") && 2 < behindTable.length() && Character.isWhitespace(behindTable.charAt(2)))
         {
            patternBehindTable = Pattern.compile("AS\\s+([A-Z0-9_]+)\\s+");
         }
         else
         {
            patternBehindTable = Pattern.compile("([A-Z0-9_]+)\\s+|[A-Z0-9_]+$");
         }

         matcher = patternBehindTable.matcher(behindTable);
         if(false == matcher.find())
         {
            return null;
         }

View Full Code Here

        }
        String regexToCompareTo;
        if (right instanceof String) {
            regexToCompareTo = (String) right;
        } else if (right instanceof Pattern) {
            Pattern pattern = (Pattern) right;
            return pattern.matcher(stringToCompare);
        } else {
            regexToCompareTo = toString(right);
        }
        return Pattern.compile(regexToCompareTo).matcher(stringToCompare);
    }
View Full Code Here

     * @param left  string to compare
     * @param right regular expression to compare the string to
     */
    public static boolean matchRegex(Object left, Object right) {
        if (left == null || right == null) return false;
        Pattern pattern;
        if (right instanceof Pattern) {
            pattern = (Pattern) right;
        } else {
            pattern = Pattern.compile(toString(right));
        }
        String stringToCompare = toString(left);
        Matcher matcher = pattern.matcher(stringToCompare);
        RegexSupport.setLastMatcher(matcher);
        return matcher.matches();
    }
View Full Code Here

TOP

Related Classes of java.util.regex.Pattern$LineEnding

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.