【The Java™ Tutorials】【Regular Expressions】10. Methods of the Matcher Class

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

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容