【The Java™ Tutorials】【Regular Ex
2018-03-23 本文已影响0人
Ppian
Index Methods
-
public int start(): Returns the start index of the previous match. -
public int start(int group): Returns the start index of the subsequence captured by the given group during the previous match operation. -
public int end(): Returns the offset after the last character matched. -
public int end(int group): Returns the offset after the last character of the subsequence captured by the given group during the previous match operation.
Study Methods
-
public boolean lookingAt(): Attempts to match the input sequence, starting at the beginning of the region, against the pattern. -
public boolean find(): Attempts to find the next subsequence of the input sequence that matches the pattern. -
public boolean find(int start): Resets this matcher and then attempts to find the next subsequence of the input sequence that matches the pattern, starting at the specified index. -
public boolean matches(): Attempts to match the entire region against the pattern. (matches要求整个字符串都匹配,而lookingAt不需要)
Replacement Methods
-
public String replaceAll(String replacement): Replaces every subsequence of the input sequence that matches the pattern with the given replacement string. -
public String replaceFirst(String replacement): Replaces the first subsequence of the input sequence that matches the pattern with the given replacement string. -
public Matcher appendReplacement(StringBuffer sb, String replacement): Implements a non-terminal append-and-replace step. -
public StringBuffer appendTail(StringBuffer sb): Implements a terminal append-and-replace step.