本文整理汇总了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;
}
示例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;
}
示例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;
}