All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fitnesse.testsystems.slim.GlobComparator Maven / Gradle / Ivy

There is a newer version: 20241026
Show newest version
package fitnesse.testsystems.slim;

import java.util.regex.Pattern;

public class GlobComparator implements CustomComparator {

  @Override
  public boolean matches(String actual, String expected) {
    return globToRegExp(expected).matcher(actual).matches();
  }

  private Pattern globToRegExp(String glob) {
    return Pattern.compile("^\\Q" + glob.replace("*", "\\E.*\\Q").replace("?", "\\E.\\Q") + "\\E$", Pattern.DOTALL);
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy