You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some regexes contain (potentially long) lists of words. E.g. almost every language over at Prism has at least one regex like this.
For many of those lists, the order of alternatives doesn't matter. I.e. most word lists in Prism are surrounded with \bs. In this case, we are free to reorder (=sort) the alternatives.
Sorting these lists is beneficial because it makes it easier for humans to find words. This makes it easier to maintain the regexes containing these lists.
Another additional advantage is that compression algorithms (e.g. gzip) are typically able to better compress sorted lists. I tested this with a few examples and sorted lists were around 10% smaller when compressed with gzip.
Some regexes contain (potentially long) lists of words. E.g. almost every language over at Prism has at least one regex like this.
For many of those lists, the order of alternatives doesn't matter. I.e. most word lists in Prism are surrounded with
\b
s. In this case, we are free to reorder (=sort) the alternatives.Sorting these lists is beneficial because it makes it easier for humans to find words. This makes it easier to maintain the regexes containing these lists.
Another additional advantage is that compression algorithms (e.g. gzip) are typically able to better compress sorted lists. I tested this with a few examples and sorted lists were around 10% smaller when compressed with gzip.
This rule is basically
order-in-character-class
but for groups.The text was updated successfully, but these errors were encountered: