From c3311f518cf09e7b9a4c194badb98e8f5b3e0bed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Robert=20J=C3=A4schke?= <jaeschke@l3s.de>
Date: Tue, 22 Jan 2019 14:03:07 +0100
Subject: [PATCH] =?UTF-8?q?+Regex-=C3=9Cbung?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 notebooks/uebung_regex.ipynb | 67 ++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)
 create mode 100644 notebooks/uebung_regex.ipynb

diff --git a/notebooks/uebung_regex.ipynb b/notebooks/uebung_regex.ipynb
new file mode 100644
index 0000000..9d9d240
--- /dev/null
+++ b/notebooks/uebung_regex.ipynb
@@ -0,0 +1,67 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# 12. Ãœbungsblatt\n",
+    "\n",
+    "Mit diesem Python-Code können Sie Ihren regulären Ausdruck testen:"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "import re\n",
+    "\n",
+    "\"\"\"\n",
+    "Ändern Sie den folgenden regulären Ausdruck, so dass alle \n",
+    "positiven Muster erkannt werden, aber kein negatives Muster.\n",
+    "\"\"\"\n",
+    "muster = re.compile(\"ap.*t\") \n",
+    "positive = [\n",
+    "    \"rap them\",\n",
+    "    \"tapeth\",\n",
+    "    \"apth\",\n",
+    "    \"wrap/try\",\n",
+    "    \"sap tray\",\n",
+    "    \"87ap9th\",\n",
+    "    \"apothecary\"\n",
+    "]\n",
+    "\n",
+    "negative = [\n",
+    "    \"aleht\",\n",
+    "    \"happy them\",\n",
+    "    \"tarpth\",\n",
+    "    \"Apt\",\n",
+    "    \"peth\",\n",
+    "    \"tarreth\",\n",
+    "    \"ddapdg\",\n",
+    "    \"apples\",\n",
+    "    \"shape the\"\n",
+    "]\n",
+    "\n",
+    "# testen, ob alle positiven Muster richtig erkannt werden\n",
+    "positive_not_matched = [s for s in positive if not muster.findall(s)]\n",
+    "if positive_not_matched:\n",
+    "    print(\"Folgende positive Muster wurden nicht erkannt:\", \", \".join(positive_not_matched))\n",
+    "\n",
+    "# testen, ob keine negativen Muster erkannt werden\n",
+    "negative_matched = [s for s in negative if muster.findall(s)]\n",
+    "if negative_matched:\n",
+    "    print(\"Folgende negativen Muster wurden erkannt:\", \", \".join(negative_matched))\n"
+   ]
+  }
+ ],
+ "metadata": {
+  "language_info": {
+   "name": "python",
+   "pygments_lexer": "ipython3"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
-- 
GitLab