本文整理了Java中java.util.regex.Matcher.match()
方法的一些代码示例,展示了Matcher.match()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matcher.match()
方法的具体详情如下:
包路径:java.util.regex.Matcher
类名称:Matcher
方法名:match
[英]Initiates a search for an anchored match to a Pattern within the given bounds. The groups are filled with default values and the match of the root of the state machine is called. The state machine will hold the state of the match as it proceeds in this matcher.
[中]启动对给定边界内模式的锚定匹配的搜索。使用默认值填充组,并调用状态机根的匹配。当状态机在此匹配器中进行匹配时,它将保持匹配的状态。
代码示例来源:origin: jtulach/bck2brwsr
/**
* Attempts to match the entire region against the pattern.
*
* <p> If the match succeeds then more information can be obtained via the
* <tt>start</tt>, <tt>end</tt>, and <tt>group</tt> methods. </p>
*
* @return <tt>true</tt> if, and only if, the entire region sequence
* matches this matcher's pattern
*/
public boolean matches() {
return match(from, ENDANCHOR);
}
代码示例来源:origin: org.apidesign.bck2brwsr/emul
/**
* Attempts to match the entire region against the pattern.
*
* <p> If the match succeeds then more information can be obtained via the
* <tt>start</tt>, <tt>end</tt>, and <tt>group</tt> methods. </p>
*
* @return <tt>true</tt> if, and only if, the entire region sequence
* matches this matcher's pattern
*/
public boolean matches() {
return match(from, ENDANCHOR);
}
代码示例来源:origin: org.apidesign.bck2brwsr/emul
/**
* Attempts to match the input sequence, starting at the beginning of the
* region, against the pattern.
*
* <p> Like the {@link #matches matches} method, this method always starts
* at the beginning of the region; unlike that method, it does not
* require that the entire region be matched.
*
* <p> If the match succeeds then more information can be obtained via the
* <tt>start</tt>, <tt>end</tt>, and <tt>group</tt> methods. </p>
*
* @return <tt>true</tt> if, and only if, a prefix of the input
* sequence matches this matcher's pattern
*/
public boolean lookingAt() {
return match(from, NOANCHOR);
}
代码示例来源:origin: jtulach/bck2brwsr
/**
* Attempts to match the input sequence, starting at the beginning of the
* region, against the pattern.
*
* <p> Like the {@link #matches matches} method, this method always starts
* at the beginning of the region; unlike that method, it does not
* require that the entire region be matched.
*
* <p> If the match succeeds then more information can be obtained via the
* <tt>start</tt>, <tt>end</tt>, and <tt>group</tt> methods. </p>
*
* @return <tt>true</tt> if, and only if, a prefix of the input
* sequence matches this matcher's pattern
*/
public boolean lookingAt() {
return match(from, NOANCHOR);
}
代码示例来源:origin: stackoverflow.com
Matcher urlMatch = url.matcher(line);
while (urlMatch.find()) urlsFound.add(urlMatch.match());
代码示例来源:origin: stackoverflow.com
final Pattern PATTERN = Pattern.compile("^\\Q(.+?)\\nyo(?:(?!cut me:|\\nyo).)*cut me:\\E", Pattern.DOTALL);
final Matcher m = PATTERN.matcher("(.+?)\\nyo(?:(?!cut me:|\\nyo).)*cut me:");
System.out.println(m.match()); // true
代码示例来源:origin: stackoverflow.com
static Pattern p = Pattern.compile("(?:P1=(\d*)),\s*(?:P2=(.*?))?,\s*(?:P3=(.*?))?,\s*(?:P4=(.*?))?,\s*(?:P5=(.*?))?");
public ReferenceData(String line) {
Matcher m = p.matcher(line);
if(m.match()){
P1 = Integer.parseInt(m.group(1));
P2 = m.group(2);//note: this can be null is P2 is not part of the line
P3 = m.group(3);
P4 = m.group(4);
P5 = m.group(5);
}
}
代码示例来源:origin: stackoverflow.com
String patternInLine = ".+\\{$";
String patternNewLine = "^\\{":
Pattern p1 = new Pattern(patternInLine);
Pattern p2 = new Pattern(patternNewLine);
while(in.hasNext()) {
String line = in.nextLine();
in.hasNextLine();
Matcher m1 = p1.match(line);
Matcher m2 = p2.match(line);
if(m1.match())
{
//inLine++;
}
else if (m2.match())
{
//newLine++;
}
else
{
//other cases
}
}
代码示例来源:origin: stackoverflow.com
public boolean match(String in) {
if(super.match(in)) return true;
if(delegate != null && delegate.match(in)) return true;
System.out.println(matcher.match( "<header ng-repeat-start=\"item in items\">"));
System.out.println(matcher.match( "var ngRepeatStart=\"item in items\">"));
内容来源于网络,如有侵权,请联系作者删除!