本文整理匯總了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;
}
}
}