regularexpression.java

来自「thinking in java 第三版英文版的源代码」· Java 代码 · 共 27 行

JAVA
27
字号
//: com:bruceeckel:simpletest:RegularExpression.java
// Regular expression for testing program output lines
package com.bruceeckel.simpletest;
import java.util.regex.*;

public class RegularExpression {
  private String regExp;
  private int numOfLines;

  public RegularExpression(String s) {
    this(s, 1);
  }

  public RegularExpression(String s, int i) {
    regExp = s;
    numOfLines = i;
  }

  public int getNumOfLines() {
    return numOfLines;
  }

  public Matcher getMatcher(CharSequence input) {
    Pattern p = Pattern.compile(regExp);
    return p.matcher(input);
  }
} ///:~

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?