Skip to content

Instantly share code, notes, and snippets.

View courtarro's full-sized avatar

Ethan Trewhitt courtarro

View GitHub Profile
@courtarro
courtarro / BetterMatcher.java
Last active December 16, 2015 21:09
Wrapper for Java's Matcher object that implements the basic MatchResult interface and provides a convenient one-call version of matches() for use in if-elseif-else statements
import java.util.regex.MatchResult;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Wrapper for the built-in object Matcher that runs a pattern matcher and saves
* the results in the same method call. Call matches() first to set up the
* internal matcher, then call the other methods to operate on the results.
*
* @author Ethan Trewhitt