import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "^(?>.*?(\\pL)(?!.*\\1)){26}";
final String string = "# Pangrams\n\n"
+ "Cwm fjord bank glyphs vext quiz.\n"
+ "Fox nymphs grab quick jived waltz.\n"
+ "Glib jocks quiz nymph to vex dwarf.\n"
+ "Quick zephyrs blow, vexing daft Jim.\n"
+ "How vexingly quick daft zebras jump!\n"
+ "Mr. Jock, TV quiz PhD, bags few lynx.\n"
+ "Sphinx of black quartz, judge my vow.\n"
+ "The five boxing wizards jump quickly.\n"
+ "Waltz, nymph, for quick jigs vex Bud.\n"
+ "Quick fox jumps nightly above wizard.\n"
+ "Jackdaws love my big sphinx of quartz.\n"
+ "Two driven jocks help fax my big quiz.\n"
+ "Fickle jinx bog dwarves spy math quiz.\n"
+ "Public junk dwarves hug my quartz fox.\n"
+ "Five quacking zephyrs jolt my wax bed.\n"
+ "Pack my box with five dozen liquor jugs.\n"
+ "Sympathizing would fix Quaker objectives.\n"
+ "When zombies arrive, quickly fax judge Pat.\n"
+ "Waxy and quivering, jocks fumble the pizza.\n"
+ "The quick brown fox jumps over the lazy dog.\n"
+ "Woven silk pyjamas exchanged for blue quartz.\n"
+ "The jay, pig, fox, zebra and my wolves quack!\n"
+ "A wizard's job is to vex chumps quickly in fog.\n"
+ "The quick onyx goblin jumps over the lazy dwarf.\n"
+ "Foxy diva Jennifer Lopez wasn't baking my quiche.\n"
+ "Watch \"Jeopardy!\", Alex Trebek's fun TV quiz game.\n"
+ "By Jove, my quick study of lexicography won a prize!\n"
+ "My girl wove six dozen plaid jackets before she quit.\n"
+ "Grumpy wizards make a toxic brew for the jovial queen.\n"
+ "A quivering Texas zombie fought republic linked jewelry.\n"
+ "The wizard quickly jinxed the gnomes before they vaporized.\n"
+ "All questions asked by five watched experts amaze the judge.\n"
+ "Back in June we delivered oxygen equipment of the same size.\n"
+ "We promptly judged antique ivory buckles for the next prize.\n"
+ "Jim quickly realized that the beautiful gowns are expensive.\n\n"
+ "# Near-pangrams (25 letters)\n\n"
+ "Cwm bank glyphs quiz vext Ford.\n"
+ "Fox nymphs grab quick jive waltz.\n"
+ "Glib jock dwarves vet ox nymph quiz.\n"
+ "Quick zephyrs blow, vexing daft Jon.\n"
+ "How vexingly quick daft zebras pump!\n"
+ "Ms. Jock, TV quiz PhD, bags few lynx.\n"
+ "Sphinges of black quartz, judge my vow.\n"
+ "The four boxing wizards jump quickly.\n"
+ "Waltz, nymph, or quick jigs vex Bud.\n"
+ "Quick fox jumps nightly over wizard.\n"
+ "Jackdaws love my big quartz sphinx.\n"
+ "Driven jocks help fax my big owl quiz.\n"
+ "Fickle jinx bog dwarves ham spy quiz.\n"
+ "Public junk dwarves hug my quartz ox.\n"
+ "Aw, five quacking zephyrs jolt my bed.\n"
+ "Pack my ox with five dozen liquor jugs.\n"
+ "Sympathizing would nix Quaker objectives.\n"
+ "When zombies arrive at fax, quickly judge.\n"
+ "Waxy jocks quivered and fumbled the pizza.\n"
+ "The quick brown fox jumps over the zany dog.\n"
+ "Exchange woven silk pyjamas for blue quartz.\n"
+ "The jays, pig, fox, zebra and my wolf quack!\n"
+ "A wizard's job is to quickly finger ex-chumps.\n"
+ "The quirky lazy dwarf jumps over the onyx bling.\n"
+ "Foxy diva Jennifer Lopez was baking my quiche.\n"
+ "Watch \"Jeopardy!\", Alex Trebek's fun quiz game.\n"
+ "By Jove, my study of quine lexicography won a prize!\n"
+ "Your girl wove six dozen plaid jackets before she quit.\n"
+ "Grumpy wizards create a toxic brew for the jovial queen.\n"
+ "A quivering Texas zombie fought ink republic jewelry.\n"
+ "The wizard quickly jinxed the gnome before he vaporized.\n"
+ "The judge asked all questions amassed by five watched experts.\n"
+ "Back in May we delivered oxygen equipment of the same size.\n"
+ "She promptly judged antique ivory buckles for the next prize.\n"
+ "Jon quickly realized that the beautiful gowns are expensive.\n\n"
+ "# Near-pangrams (23-24 letters, from MASC wordsense)\n\n"
+ "Squash has become a popular racket game and facilities are widely available.\n"
+ "Equally coveted is the sexy Y2K logo (named for the millennial computer bug).\n"
+ "Dole is sorely tempted to forget everything he knows about the 1980s tax cuts.\n"
+ "The officers have been placed on administrative duty while a grand jury examines the case.\n"
+ "Head up the hill above the town to explore the remains of the ancient Greek town of Sybrita.\n"
+ "\"I can at least partly save the movie from being wrecked by Herzog's bungling,\" writes Kinski.\n"
+ "To answer this question, Vygotsky proposed a special concept: the zone of proximal development.";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
final Matcher matcher = pattern.matcher(string);
while (matcher.find()) {
System.out.println("Full match: " + matcher.group(0));
for (int i = 1; i <= matcher.groupCount(); i++) {
System.out.println("Group " + i + ": " + matcher.group(i));
}
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html