2018-08-01 | Paul Boddie | raw files shortlog changelog graph | Added a convenience function for choices of patterns. | |
moinformat/parsers/common.py (file) |
1.1 --- a/moinformat/parsers/common.py Wed Aug 01 13:25:22 2018 +0200 1.2 +++ b/moinformat/parsers/common.py Wed Aug 01 13:32:10 2018 +0200 1.3 @@ -28,6 +28,12 @@ 1.4 ws_excl_nl = r"[ \f\r\t\v]" 1.5 quotes = "['" '"]' # ['"] 1.6 1.7 +def choice(l): 1.8 + 1.9 + "Return a pattern matching a choice of patterns in 'l'." 1.10 + 1.11 + return "(%s)" % "|".join(l) 1.12 + 1.13 def excl(s): 1.14 1.15 "Return a non-matching pattern for 's'."