From 9daa599e88d66cb7e4c4768f45630bccdf5d60fd Mon Sep 17 00:00:00 2001 From: Jan Pokorný Date: Thu, 20 Nov 2014 20:31:41 +0100 Subject: Add python/002-simple-re-within-string.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan Pokorný --- python/002-simple-re-within-string.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 python/002-simple-re-within-string.py (limited to 'python') diff --git a/python/002-simple-re-within-string.py b/python/002-simple-re-within-string.py new file mode 100644 index 0000000..5259418 --- /dev/null +++ b/python/002-simple-re-within-string.py @@ -0,0 +1,9 @@ +version_start, version_stop = reduce( + lambda acc, x: (acc[0] if acc[0] or not x[1].isdigit() else x[0]+1, + acc[0] if not x[1].isdigit() else x[0]+1), + enumerate(options.version), (0, 0) +) +if not version_start: + options.version = '0' +else: + options.version = options.version[version_start-1:version_stop] -- cgit