# HG changeset patch # User Paul Boddie # Date 1533123130 -7200 # Node ID 50aa090efd452af8f40d6815cdf9c5bacc0b9a3a # Parent 0fa67bb2a7d92763eabffbd11ac95c33e240fcee Added a convenience function for choices of patterns. diff -r 0fa67bb2a7d9 -r 50aa090efd45 moinformat/parsers/common.py --- a/moinformat/parsers/common.py Wed Aug 01 13:25:22 2018 +0200 +++ b/moinformat/parsers/common.py Wed Aug 01 13:32:10 2018 +0200 @@ -28,6 +28,12 @@ ws_excl_nl = r"[ \f\r\t\v]" quotes = "['" '"]' # ['"] +def choice(l): + + "Return a pattern matching a choice of patterns in 'l'." + + return "(%s)" % "|".join(l) + def excl(s): "Return a non-matching pattern for 's'."