public static String expand(final CharSequence pattern) {
		requireNonNull(pattern, "Pattern");
		final StringBuilder out = new StringBuilder();

		for (int i = 0, n = pattern.length(); i < n; ++i) {
			if (pattern.charAt(i) == '\\') {
				++i;
				if (i < pattern.length()) {
					out.append(pattern.charAt(i));
				}
			} else if (pattern.charAt(i) == '-') {
				if (i <= 0 || i >= (pattern.length() - 1)) {
					throw new PatternSyntaxException(
						"Dangling range operator '-'", pattern.toString(),
						pattern.length() - 1
					);
				}

				final String range = expand(
					pattern.charAt(i - 1),
					pattern.charAt(i + 1)
				);
				out.append(range);

				++i;
			} else if (i + 1 == n || pattern.charAt(i + 1) != '-') {
				out.append(pattern.charAt(i));
			}
		}

		return out.toString();
	}
Expands the character range for the given {@code pattern}. E.g.
{@code a-zA-Z0-1} will return a string containing all upper and lower
case characters (from a to z), and all digits form 0 to 9.

@param pattern the {@code pattern} to expand.
@return the expanded pattern.
@throws PatternSyntaxException if the pattern could not be expanded.
@throws NullPointerException if the pattern is {@code null}.
jenetics/src/main/java/io/jenetics/util/CharSeq.java