julycoding/The-Art-Of-Programming-By-July — pull request #270 by spance (2014-04-24 13:37:06+00:00)
Title: Update 01.03.md

修改了lookBehind为尾匹配方式（属线性复杂度且降低常数），并改递归为循环

测试方法在下面，请July根据需要看是否要增加进去：

```java

// 若干测试
public static void main(String[] args) {
assertAndPrint(WildCardMatcher.matches("assbsavb", "a*b"), "assbsavb");
assertAndPrint(WildCardMatcher.matches("assbsavb", "a??b"), "assb");
assertAndPrint(WildCardMatcher.matches("assbsavb", "a?b"), "avb");
assertAndPrint(WildCardMatcher.matches("assbsavbz", "a??"), "ass", "avb");
assertAndPrint(WildCardMatcher.matches("assbsavbz", "?"));
assertAndPrint(WildCardMatcher.matches("assbsavbz", "??sb"), "assb");
assertAndPrint(WildCardMatcher.matches("assbsavbz", "b*s"), "bs");
assertAndPrint(WildCardMatcher.matches("assbsavbz", "?s"), "as", "bs");
assertAndPrint(WildCardMatcher.matches("assbsavbz", "s?"), "ss", "sa");
assertAndPrint(WildCardMatcher.matches("assbsavbz", "s?s"), "sbs");
assertAndPrint(WildCardMatcher.matches("assbsavbz", "s"));
assertAndPrint(WildCardMatcher.matches("assbsavbz", "z"));
assertAndPrint(WildCardMatcher.matches("assbsavbz", "Z"));
assertAndPrint(WildCardMatcher.matches("assbsavbz", "s?b?a"), "ssbsa");
assertAndPrint(WildCardMatcher.matches("assbsavbcsb", "a*sb"), "assbsavbcsb");
assertAndPrint(WildCardMatcher.matches("assbsavbcsb", "a*s*b"), "assbsavbcsb");
assertAndPrint(WildCardMatcher.matches("assbsavbcsb", "a*s?"), "assbsavbcsb");
assertAndPrint(WildCardMatcher.matches("assbsavbcsb", "a*a?b"), "assbsavb");

String file = readExternal();
int loop = 100;
int count = 0;
String[] pc = "".split("\\*+");
long t1 = System.currentTimeMillis();
for (int i = 0; i < loop; i++) {
count += WildCardMatcher.matches(file, pc).size();
}
long t2 = System.currentTimeMillis();
System.out.printf("wildcard matcher time=%d, count=%d %n", t2 - t1, count);

count = 0;
Pattern pa = Pattern.compile("()");
t1 = System.currentTimeMillis();
for (int i = 0; i < loop; i++) {
java.util.regex.Matcher ma = pa.matcher(file);
while (ma.find()) {
count += ma.groupCount();
}
}
t2 = System.currentTimeMillis();
System.out.printf("regex matcher time=%d, count=%d %n", t2 - t1, count);
}

```