本文整理汇总了Java中java.util.regex.Matcher.pattern方法的典型用法代码示例。如果您正苦于以下问题:Java Matcher.pattern方法的具体用法?Java Matcher.pattern怎么用?Java Matcher.pattern使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.regex.Matcher
的用法示例。
在下文中一共展示了Matcher.pattern方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseNormalRange
import java.util.regex.Matcher; //导入方法依赖的package包/类
private void parseNormalRange(Hunk hunk, Matcher m) {
if (m.pattern() == normalAddRangePattern) {
hunk.baseStart = Integer.parseInt(m.group(1));
hunk.baseCount = 0;
hunk.modifiedStart = Integer.parseInt(m.group(2));
hunk.modifiedCount = Integer.parseInt(m.group(3)) - hunk.modifiedStart + 1;
} else if (m.pattern() == normalDeleteRangePattern) {
hunk.baseStart = Integer.parseInt(m.group(1));
hunk.baseCount = Integer.parseInt(m.group(2)) - hunk.baseStart + 1;
hunk.modifiedStart = Integer.parseInt(m.group(3));
hunk.modifiedCount = 0;
} else {
hunk.baseStart = Integer.parseInt(m.group(1));
if (m.group(3) != null) {
hunk.baseCount = Integer.parseInt(m.group(3)) - hunk.baseStart + 1;
} else {
hunk.baseCount = 1;
}
hunk.modifiedStart = Integer.parseInt(m.group(4));
if (m.group(6) != null) {
hunk.modifiedCount = Integer.parseInt(m.group(6)) - hunk.modifiedStart + 1;
} else {
hunk.modifiedCount = 1;
}
}
}
示例2: apply
import java.util.regex.Matcher; //导入方法依赖的package包/类
@Override
public Result<MatchResult> apply(String input) {
Matcher matcher = pattern.matcher(input);
if (matcher.lookingAt()) {
return new Accept<>(matcher.toMatchResult(), input.substring(matcher.end()));
} else {
return new Reject<>(input + " does not match " + matcher.pattern());
}
}
示例3: parseNormalRange
import java.util.regex.Matcher; //导入方法依赖的package包/类
private void parseNormalRange(Hunk hunk, Matcher m) {
if (m.pattern() == normalAddRangePattern) {
hunk.baseStart = Integer.parseInt(m.group(1));
hunk.baseCount = 0;
hunk.modifiedStart = Integer.parseInt(m.group(2));
hunk.modifiedCount = Integer.parseInt(m.group(3))
- hunk.modifiedStart + 1;
} else if (m.pattern() == normalDeleteRangePattern) {
hunk.baseStart = Integer.parseInt(m.group(1));
hunk.baseCount = Integer.parseInt(m.group(2)) - hunk.baseStart
+ 1;
hunk.modifiedStart = Integer.parseInt(m.group(3));
hunk.modifiedCount = 0;
} else {
hunk.baseStart = Integer.parseInt(m.group(1));
if (m.group(3) != null) {
hunk.baseCount = Integer.parseInt(m.group(3))
- hunk.baseStart
+ 1;
} else {
hunk.baseCount = 1;
}
hunk.modifiedStart = Integer.parseInt(m.group(4));
if (m.group(6) != null) {
hunk.modifiedCount = Integer.parseInt(m.group(6))
- hunk.modifiedStart + 1;
} else {
hunk.modifiedCount = 1;
}
}
}