Character class subtraction, converting from Java syntax to RegexBuddy

Like most regex flavors, java.util.regex.Pattern has its own specific features with syntax that may not be fully compatible with others; this includes character class union, intersection and subtraction: [a-d[m-p]] : a through d, or m through p: [a-dm-p] (union) [a-z&&[def]] : d, e, or f (intersection) [a-z&&[^bc]] : a through z, except for b and … Read more

Why is a character class faster than alternation?

This is because the “OR” construct | backtracks between the alternation: If the first alternation is not matched, the engine has to return before the pointer location moved during the match of the alternation, to continue matching the next alternation; Whereas the character class can advance sequentially. See this match on a regex engine with … Read more