當前位置: 首頁>>代碼示例>>Java>>正文


Java Perl5Compiler.SINGLELINE_MASK屬性代碼示例

本文整理匯總了Java中org.apache.oro.text.regex.Perl5Compiler.SINGLELINE_MASK屬性的典型用法代碼示例。如果您正苦於以下問題:Java Perl5Compiler.SINGLELINE_MASK屬性的具體用法?Java Perl5Compiler.SINGLELINE_MASK怎麽用?Java Perl5Compiler.SINGLELINE_MASK使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.apache.oro.text.regex.Perl5Compiler的用法示例。


在下文中一共展示了Perl5Compiler.SINGLELINE_MASK屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: indexOf

/**
 * return index of the first occurence of the pattern in input text
 * @param strPattern pattern to search
 * @param strInput text to search pattern
 * @param offset 
 * @param caseSensitive
 * @return position of the first occurence
 * @throws MalformedPatternException
*/
public static int indexOf(String strPattern, String strInput, int offset, boolean caseSensitive) throws MalformedPatternException {
       //Perl5Compiler compiler = new Perl5Compiler();
       PatternMatcherInput input = new PatternMatcherInput(strInput);
       Perl5Matcher matcher = new Perl5Matcher();
       
       int compileOptions=caseSensitive ? 0 : Perl5Compiler.CASE_INSENSITIVE_MASK;
       compileOptions+=Perl5Compiler.SINGLELINE_MASK;
       if(offset < 1) offset = 1;
       
       Pattern pattern = getPattern(strPattern,compileOptions);
       //Pattern pattern = compiler.compile(strPattern,compileOptions);
       

       if(offset <= strInput.length()) input.setCurrentOffset(offset - 1);
       
       if(offset <= strInput.length() && matcher.contains(input, pattern)) {
           return matcher.getMatch().beginOffset(0) + 1; 
       }
       return 0;
   }
 
開發者ID:lucee,項目名稱:Lucee4,代碼行數:29,代碼來源:Perl5Util.java

示例2: getCompilerOptions

/**
 * Convert the generic options to the regex compiler specific options.
 * @param options the generic options
 * @return the specific options
 */
protected int getCompilerOptions(final int options) {
    int cOptions = Perl5Compiler.DEFAULT_MASK;

    if (RegexpUtil.hasFlag(options, MATCH_CASE_INSENSITIVE)) {
        cOptions |= Perl5Compiler.CASE_INSENSITIVE_MASK;
    }
    if (RegexpUtil.hasFlag(options, MATCH_MULTILINE)) {
        cOptions |= Perl5Compiler.MULTILINE_MASK;
    }
    if (RegexpUtil.hasFlag(options, MATCH_SINGLELINE)) {
        cOptions |= Perl5Compiler.SINGLELINE_MASK;
    }

    return cOptions;
}
 
開發者ID:apache,項目名稱:ant,代碼行數:20,代碼來源:JakartaOroMatcher.java

示例3: match

public static Array match(String strPattern, String strInput, int offset, boolean caseSensitive) throws MalformedPatternException {
    
    Perl5Matcher matcher = new Perl5Matcher();
    PatternMatcherInput input = new PatternMatcherInput(strInput);
    
    
    int compileOptions=caseSensitive ? 0 : Perl5Compiler.CASE_INSENSITIVE_MASK;
    compileOptions+=Perl5Compiler.SINGLELINE_MASK;
    if(offset < 1) offset = 1;
    
    
    Pattern pattern = getPattern(strPattern,compileOptions);
    
    
    Array rtn = new ArrayImpl();
    MatchResult result;
    while(matcher.contains(input, pattern)) {
      result = matcher.getMatch();  
      rtn.appendEL(result.toString());
      /*
      System.out.println("Match: " + result.toString());
      System.out.println("Length: " + result.length());
      groups = result.groups();
      System.out.println("Groups: " + groups);
      System.out.println("Begin offset: " + result.beginOffset(0));
      System.out.println("End offset: " + result.endOffset(0));
      System.out.println("Saved Groups: ");

      // Start at 1 because we just printed out group 0
      for(int group = 1; group < groups; group++) {
    	  System.out.println(group + ": " + result.group(group));
    	  System.out.println("Begin: " + result.begin(group));
    	  System.out.println("End: " + result.end(group));
      }*/
    }
    return rtn;
}
 
開發者ID:lucee,項目名稱:Lucee4,代碼行數:37,代碼來源:Perl5Util.java


注:本文中的org.apache.oro.text.regex.Perl5Compiler.SINGLELINE_MASK屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。