From 433b4373e4a87b8858973dc4b4002f24c65f2ab2 Mon Sep 17 00:00:00 2001 From: Michael Leuschel <leuschel@uni-duesseldorf.de> Date: Mon, 11 May 2020 15:38:51 +0200 Subject: [PATCH] more examples and intro to regexes --- info4/kapitel-2/RegulaereAusdruecke.ipynb | 619 +++++++++++++++++++++- 1 file changed, 593 insertions(+), 26 deletions(-) diff --git a/info4/kapitel-2/RegulaereAusdruecke.ipynb b/info4/kapitel-2/RegulaereAusdruecke.ipynb index c319f56..09323d4 100644 --- a/info4/kapitel-2/RegulaereAusdruecke.ipynb +++ b/info4/kapitel-2/RegulaereAusdruecke.ipynb @@ -25,6 +25,56 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "## Sprache regulärer Ausdrücke\n", + "\n", + "Sei $\\Sigma$ ein Alphabet.\n", + "Jedem regulären Ausdruck $\\gamma$ ist in\n", + " eindeutiger Weise eine Sprache $L(\\gamma) \\subseteq \\Sigma^*$\n", + " zugeordnet (wir sagen: $\\gamma$ beschreibt\n", + " $L(\\gamma)$), die so definiert ist:\n", + "\n", + "$L(\\gamma)$ = \n", + "* $\\emptyset$ falls $\\gamma = \\emptyset$\n", + "* $\\{\\lambda\\}$ falls $\\gamma = \\lambda$\n", + "* $\\{a\\}$ falls $\\gamma = a$ für ein $a \\in \\Sigma$\n", + "* $L(\\alpha) L(\\beta)$ falls $\\gamma = \\alpha \\beta$\n", + "* $L(\\alpha) \\cup L(\\beta)$ falls $\\gamma = (\\alpha + \\beta)$" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Zwei reguläre Ausdrücke $\\alpha_1$ und $\\alpha_2$ heißen\n", + " __äquivalent__ (kurz $\\alpha_1 \\sim \\alpha_2$), falls\n", + " $L(\\alpha_1)=L(\\alpha_2)$." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Es sei $\\Sigma=\\{a,b\\}$.\n", + "Der reguläre Ausdruck \n", + "* $\\alpha_1 = (\\lambda + a(a+b)^{*})$\n", + "beschreibt die Sprache\n", + "* $L(\\alpha_1) = \\{\\lambda\\} \\cup \\{ax \\mid x \\in \\{a,b\\}^{*}\\}$\n", + "d.h. das leere Wort und alle Wörter über $\\Sigma$, die mit $a$\n", + "beginnen.\n", + "\n", + "Der reguläre Ausdruck\n", + "* $\\alpha_2 = ((a+b)^* ab)$\n", + "beschreibt die Sprache:\n", + "* $L(\\alpha_2) = \\{xab \\mid x \\in \\{a,b\\}^{*}\\}$\n", + "d.h. alle Wörter über $\\Sigma$, die mit $ab$ enden." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Reguläre Ausdrücke in der Praxis\n", + "\n", "Um mit den praktischen Aspekten der regulären Ausdrücke zu experimentieren laden wir eine Bibliothek.\n", "In dieser Bibliothek wird der Plus Operator anders geschrieben: ```a|b```.\n", "Es gibt nicht den regulären Ausdruck $\\emptyset$, aber dafür viele andere (abgeleitete) Operatoren (syntaktische Zucker), zum Beispiel:\n", @@ -35,7 +85,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 1, "metadata": {}, "outputs": [ { @@ -44,7 +94,7 @@ "Loaded machine: Regex" ] }, - "execution_count": 19, + "execution_count": 1, "metadata": {}, "output_type": "execute_result" } @@ -58,7 +108,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 2, "metadata": {}, "outputs": [ { @@ -67,7 +117,7 @@ "Machine initialised using operation 0: $initialise_machine()" ] }, - "execution_count": 20, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } @@ -85,7 +135,7 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -97,7 +147,7 @@ "TRUE" ] }, - "execution_count": 47, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -108,7 +158,7 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -120,7 +170,7 @@ "TRUE" ] }, - "execution_count": 46, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } @@ -131,7 +181,7 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -143,7 +193,7 @@ "TRUE" ] }, - "execution_count": 43, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -154,9 +204,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\mathit{TRUE}$" + ], + "text/plain": [ + "TRUE" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "REGEX_MATCH(\"\",\"a*\")" ] @@ -171,7 +235,7 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -183,7 +247,7 @@ "rec(length∈3,position∈1,string∈\"aab\",submatches∈∅)" ] }, - "execution_count": 48, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -201,7 +265,7 @@ }, { "cell_type": "code", - "execution_count": 50, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -213,7 +277,7 @@ "{(1↦\"aab\"),(2↦\"bb\"),(3↦\"a\")}" ] }, - "execution_count": 50, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -232,7 +296,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -244,7 +308,7 @@ "\"\\nFAUST:\\n Habe nun, ach! Philosophie,\\n Juristerei und Medizin,\\n Und leider auch Theologie\\n Durchaus studiert, mit heißem Bemühn.\\n Da steh ich nun, ich armer Tor!\\n Und bin so klug als wie zuvor;\\n Heiße Magister, heiße Doktor gar\\n Und ziehe schon an die zehen Jahr\\n Herauf, herab und quer und krumm\\n Meine Schüler an der Nase herum-\\n Und sehe, daß wir nichts wissen können!\\n Das will mir schier das Herz verbrennen.\\n Zwar bin ich gescheiter als all die Laffen,\\n Doktoren, Magister, Schreiber und Pfaffen;\\n Mich plagen keine Skrupel noch Zweifel,\\n Fürchte mich weder vor Hölle noch Teufel-\\n Dafür ist mir auch alle Freud entrissen,\\n Bilde mir nicht ein, was Rechts zu wissen,\\n Bilde mir nicht ein, ich könnte was lehren,\\n Die Menschen zu bessern und zu bekehren.\\n Auch hab ich weder Gut noch Geld,\\n Noch Ehr und Herrlichkeit der Welt;\\n Es möchte kein Hund so länger leben!\\n Drum hab ich mich der Magie ergeben,\\n Ob mir durch Geistes Kraft und Mund\\n Nicht manch Geheimnis würde kund;\\n Daß ich nicht mehr mit saurem Schweiß\\n Zu sagen brauche, was ich nicht weiß;\\n Daß ich erkenne, was die Welt\\n Im Innersten zusammenhält,\\n Schau alle Wirkenskraft und Samen,\\n Und tu nicht mehr in Worten kramen.\\n \"" ] }, - "execution_count": 31, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -289,7 +353,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -301,7 +365,7 @@ "{(1↦\"ich\"),(2↦\"ich\"),(3↦\"ich\"),(4↦\"ich\"),(5↦\"ich\"),(6↦\"ich\"),(7↦\"ich\"),(8↦\"ich\"),(9↦\"ich\"),(10↦\"ich\"),(11↦\"ich\"),(12↦\"ich\"),(13↦\"ich\"),(14↦\"ich\"),(15↦\"ich\"),(16↦\"ich\"),(17↦\"ich\"),(18↦\"ich\"),(19↦\"ich\"),(20↦\"ich\")}" ] }, - "execution_count": 32, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -312,7 +376,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -324,7 +388,7 @@ "rec(length∈3,position∈802,string∈\"Gut\",submatches∈∅)" ] }, - "execution_count": 35, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -335,7 +399,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -347,7 +411,7 @@ "{(1↦\"Gut\"),(2↦\"Geld\"),(3↦\"Geistes\"),(4↦\"Geheimnis\")}" ] }, - "execution_count": 36, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -358,11 +422,514 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": null, "metadata": {}, "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Zusätzlich zu * und + gibt es ein Reihe weiter Wiederholungsoperatoren:\n", + "* ```R?``` 0 oder 1 Wiederholung von R\n", + "* ```R{n}``` $n$ Wiederholungen von R\n", + "* ```R{n,}``` $n$ oder mehr Wiederholungen von R\n", + "* ```R{m,n}``` $m$ bis $n$ Wiederholungen von R\n" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{(1\\mapsto\\text{\"Geld\"}),(2\\mapsto\\text{\"Geis\"}),(3\\mapsto\\text{\"Gehe\"})\\}$" + ], + "text/plain": [ + "{(1↦\"Geld\"),(2↦\"Geis\"),(3↦\"Gehe\")}" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "REGEX_SEARCH_ALL(txt,\"G[a-z]{3}\")" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{(1\\mapsto\\text{\"Geld\"}),(2\\mapsto\\text{\"Geistes\"}),(3\\mapsto\\text{\"Geheimnis\"})\\}$" + ], + "text/plain": [ + "{(1↦\"Geld\"),(2↦\"Geistes\"),(3↦\"Geheimnis\")}" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "REGEX_SEARCH_ALL(txt,\"G[a-z]{3,}\")" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{(1\\mapsto\\text{\"Gut\"}),(2\\mapsto\\text{\"Geld\"}),(3\\mapsto\\text{\"Geis\"}),(4\\mapsto\\text{\"Gehe\"})\\}$" + ], + "text/plain": [ + "{(1↦\"Gut\"),(2↦\"Geld\"),(3↦\"Geis\"),(4↦\"Gehe\")}" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "REGEX_SEARCH_ALL(txt,\"G[a-z]{2,3}\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Es gibt natürlich in der Praxis noch eine Reihe an Sonderzeichen die man erkennen will.\n", + "Man kann deshalb alle Symbole der Syntax der regulären Ausdruckssprache mit ```\\``` escapen. So zum Beispiel, ```a\\|b``` oder ```a\\+```:\n" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\renewcommand{\\emptyset}{\\mathord\\varnothing}\\mathit{rec}(\\mathit{length}\\in 1,\\mathit{position}\\in 1,\\mathit{string}\\in\\text{\"a\"},\\mathit{submatches}\\in\\emptyset)$" + ], + "text/plain": [ + "rec(length∈1,position∈1,string∈\"a\",submatches∈∅)" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "REGEX_SEARCH(\"abca|bd\",1,\"a|b\")" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\renewcommand{\\emptyset}{\\mathord\\varnothing}\\mathit{rec}(\\mathit{length}\\in 3,\\mathit{position}\\in 4,\\mathit{string}\\in\\text{\"a|b\"},\\mathit{submatches}\\in\\emptyset)$" + ], + "text/plain": [ + "rec(length∈3,position∈4,string∈\"a|b\",submatches∈∅)" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "REGEX_SEARCH(\"abca|bd\",1,\"a\\|b\")" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\renewcommand{\\emptyset}{\\mathord\\varnothing}\\mathit{rec}(\\mathit{length}\\in 1,\\mathit{position}\\in 1,\\mathit{string}\\in\\text{\"a\"},\\mathit{submatches}\\in\\emptyset)$" + ], + "text/plain": [ + "rec(length∈1,position∈1,string∈\"a\",submatches∈∅)" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "REGEX_SEARCH(\"abca+bd\",1,\"a+\")" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\renewcommand{\\emptyset}{\\mathord\\varnothing}\\mathit{rec}(\\mathit{length}\\in 2,\\mathit{position}\\in 4,\\mathit{string}\\in\\text{\"a+\"},\\mathit{submatches}\\in\\emptyset)$" + ], + "text/plain": [ + "rec(length∈2,position∈4,string∈\"a+\",submatches∈∅)" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "REGEX_SEARCH(\"abca+bd\",1,\"a\\+\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Es gibt auch verschiedene besondere Zeichen:\n", + "* ```\\d``` für eine Ziffer\n", + "* ```\\D``` für ein Zeichen, dass keine Ziffer ist\n", + "* ```\\s``` für ein Leerzeichen\n", + "* ```\\S``` für ein Zeichen, dass kein Leerzeichen ist\n", + "* ```\\w``` für ein alpha-numerisches Zeichen oder den Underscore\n", + "* ```\\W``` für ein Zeichen, dass kein alpha-numerisches Zeichen und kein Underscore ist\n", + "* ```.``` für all Zeichen ausser Zeilenumbrüche\n", + "* ```\\n``` für einen Zeilenumbruch\n", + "* ```\\t``` für ein Tabulatorzeichen\n" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{(1\\mapsto\\text{\"ab\"}),(2\\mapsto\\text{\"cd\"}),(3\\mapsto\\text{\"ef\"})\\}$" + ], + "text/plain": [ + "{(1↦\"ab\"),(2↦\"cd\"),(3↦\"ef\")}" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "REGEX_SEARCH_ALL(\"ab cd ef\",\"\\w+\")" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{(1\\mapsto\\text{\"FAUST\"}),(2\\mapsto\\text{\"Habe\"}),(3\\mapsto\\text{\"nun\"}),(4\\mapsto\\text{\"ach\"}),(5\\mapsto\\text{\"Philosophie\"}),(6\\mapsto\\text{\"Juristerei\"}),(7\\mapsto\\text{\"und\"}),(8\\mapsto\\text{\"Medizin\"}),(9\\mapsto\\text{\"Und\"}),(10\\mapsto\\text{\"leider\"}),(11\\mapsto\\text{\"auch\"}),(12\\mapsto\\text{\"Theologie\"}),(13\\mapsto\\text{\"Durchaus\"}),(14\\mapsto\\text{\"studiert\"}),(15\\mapsto\\text{\"mit\"}),(16\\mapsto\\text{\"heißem\"}),(17\\mapsto\\text{\"Bemühn\"}),(18\\mapsto\\text{\"Da\"}),(19\\mapsto\\text{\"steh\"}),(20\\mapsto\\text{\"ich\"}),(21\\mapsto\\text{\"nun\"}),(22\\mapsto\\text{\"ich\"}),(23\\mapsto\\text{\"armer\"}),(24\\mapsto\\text{\"Tor\"}),(25\\mapsto\\text{\"Und\"}),(26\\mapsto\\text{\"bin\"}),(27\\mapsto\\text{\"so\"}),(28\\mapsto\\text{\"klug\"}),(29\\mapsto\\text{\"als\"}),(30\\mapsto\\text{\"wie\"}),(31\\mapsto\\text{\"zuvor\"}),(32\\mapsto\\text{\"Heiße\"}),(33\\mapsto\\text{\"Magister\"}),(34\\mapsto\\text{\"heiße\"}),(35\\mapsto\\text{\"Doktor\"}),(36\\mapsto\\text{\"gar\"}),(37\\mapsto\\text{\"Und\"}),(38\\mapsto\\text{\"ziehe\"}),(39\\mapsto\\text{\"schon\"}),(40\\mapsto\\text{\"an\"}),(41\\mapsto\\text{\"die\"}),(42\\mapsto\\text{\"zehen\"}),(43\\mapsto\\text{\"Jahr\"}),(44\\mapsto\\text{\"Herauf\"}),(45\\mapsto\\text{\"herab\"}),(46\\mapsto\\text{\"und\"}),(47\\mapsto\\text{\"quer\"}),(48\\mapsto\\text{\"und\"}),(49\\mapsto\\text{\"krumm\"}),(50\\mapsto\\text{\"Meine\"}),(51\\mapsto\\text{\"Schüler\"}),(52\\mapsto\\text{\"an\"}),(53\\mapsto\\text{\"der\"}),(54\\mapsto\\text{\"Nase\"}),(55\\mapsto\\text{\"herum\"}),(56\\mapsto\\text{\"Und\"}),(57\\mapsto\\text{\"sehe\"}),(58\\mapsto\\text{\"daß\"}),(59\\mapsto\\text{\"wir\"}),(60\\mapsto\\text{\"nichts\"}),(61\\mapsto\\text{\"wissen\"}),(62\\mapsto\\text{\"können\"}),(63\\mapsto\\text{\"Das\"}),(64\\mapsto\\text{\"will\"}),(65\\mapsto\\text{\"mir\"}),(66\\mapsto\\text{\"schier\"}),(67\\mapsto\\text{\"das\"}),(68\\mapsto\\text{\"Herz\"}),(69\\mapsto\\text{\"verbrennen\"}),(70\\mapsto\\text{\"Zwar\"}),(71\\mapsto\\text{\"bin\"}),(72\\mapsto\\text{\"ich\"}),(73\\mapsto\\text{\"gescheiter\"}),(74\\mapsto\\text{\"als\"}),(75\\mapsto\\text{\"all\"}),(76\\mapsto\\text{\"die\"}),(77\\mapsto\\text{\"Laffen\"}),(78\\mapsto\\text{\"Doktoren\"}),(79\\mapsto\\text{\"Magister\"}),(80\\mapsto\\text{\"Schreiber\"}),(81\\mapsto\\text{\"und\"}),(82\\mapsto\\text{\"Pfaffen\"}),(83\\mapsto\\text{\"Mich\"}),(84\\mapsto\\text{\"plagen\"}),(85\\mapsto\\text{\"keine\"}),(86\\mapsto\\text{\"Skrupel\"}),(87\\mapsto\\text{\"noch\"}),(88\\mapsto\\text{\"Zweifel\"}),(89\\mapsto\\text{\"Fürchte\"}),(90\\mapsto\\text{\"mich\"}),(91\\mapsto\\text{\"weder\"}),(92\\mapsto\\text{\"vor\"}),(93\\mapsto\\text{\"Hölle\"}),(94\\mapsto\\text{\"noch\"}),(95\\mapsto\\text{\"Teufel\"}),(96\\mapsto\\text{\"Dafür\"}),(97\\mapsto\\text{\"ist\"}),(98\\mapsto\\text{\"mir\"}),(99\\mapsto\\text{\"auch\"}),(100\\mapsto\\text{\"alle\"}),(101\\mapsto\\text{\"Freud\"}),(102\\mapsto\\text{\"entrissen\"}),(103\\mapsto\\text{\"Bilde\"}),(104\\mapsto\\text{\"mir\"}),(105\\mapsto\\text{\"nicht\"}),(106\\mapsto\\text{\"ein\"}),(107\\mapsto\\text{\"was\"}),(108\\mapsto\\text{\"Rechts\"}),(109\\mapsto\\text{\"zu\"}),(110\\mapsto\\text{\"wissen\"}),(111\\mapsto\\text{\"Bilde\"}),(112\\mapsto\\text{\"mir\"}),(113\\mapsto\\text{\"nicht\"}),(114\\mapsto\\text{\"ein\"}),(115\\mapsto\\text{\"ich\"}),(116\\mapsto\\text{\"könnte\"}),(117\\mapsto\\text{\"was\"}),(118\\mapsto\\text{\"lehren\"}),(119\\mapsto\\text{\"Die\"}),(120\\mapsto\\text{\"Menschen\"}),(121\\mapsto\\text{\"zu\"}),(122\\mapsto\\text{\"bessern\"}),(123\\mapsto\\text{\"und\"}),(124\\mapsto\\text{\"zu\"}),(125\\mapsto\\text{\"bekehren\"}),(126\\mapsto\\text{\"Auch\"}),(127\\mapsto\\text{\"hab\"}),(128\\mapsto\\text{\"ich\"}),(129\\mapsto\\text{\"weder\"}),(130\\mapsto\\text{\"Gut\"}),(131\\mapsto\\text{\"noch\"}),(132\\mapsto\\text{\"Geld\"}),(133\\mapsto\\text{\"Noch\"}),(134\\mapsto\\text{\"Ehr\"}),(135\\mapsto\\text{\"und\"}),(136\\mapsto\\text{\"Herrlichkeit\"}),(137\\mapsto\\text{\"der\"}),(138\\mapsto\\text{\"Welt\"}),(139\\mapsto\\text{\"Es\"}),(140\\mapsto\\text{\"möchte\"}),(141\\mapsto\\text{\"kein\"}),(142\\mapsto\\text{\"Hund\"}),(143\\mapsto\\text{\"so\"}),(144\\mapsto\\text{\"länger\"}),(145\\mapsto\\text{\"leben\"}),(146\\mapsto\\text{\"Drum\"}),(147\\mapsto\\text{\"hab\"}),(148\\mapsto\\text{\"ich\"}),(149\\mapsto\\text{\"mich\"}),(150\\mapsto\\text{\"der\"}),(151\\mapsto\\text{\"Magie\"}),(152\\mapsto\\text{\"ergeben\"}),(153\\mapsto\\text{\"Ob\"}),(154\\mapsto\\text{\"mir\"}),(155\\mapsto\\text{\"durch\"}),(156\\mapsto\\text{\"Geistes\"}),(157\\mapsto\\text{\"Kraft\"}),(158\\mapsto\\text{\"und\"}),(159\\mapsto\\text{\"Mund\"}),(160\\mapsto\\text{\"Nicht\"}),(161\\mapsto\\text{\"manch\"}),(162\\mapsto\\text{\"Geheimnis\"}),(163\\mapsto\\text{\"würde\"}),(164\\mapsto\\text{\"kund\"}),(165\\mapsto\\text{\"Daß\"}),(166\\mapsto\\text{\"ich\"}),(167\\mapsto\\text{\"nicht\"}),(168\\mapsto\\text{\"mehr\"}),(169\\mapsto\\text{\"mit\"}),(170\\mapsto\\text{\"saurem\"}),(171\\mapsto\\text{\"Schweiß\"}),(172\\mapsto\\text{\"Zu\"}),(173\\mapsto\\text{\"sagen\"}),(174\\mapsto\\text{\"brauche\"}),(175\\mapsto\\text{\"was\"}),(176\\mapsto\\text{\"ich\"}),(177\\mapsto\\text{\"nicht\"}),(178\\mapsto\\text{\"weiß\"}),(179\\mapsto\\text{\"Daß\"}),(180\\mapsto\\text{\"ich\"}),(181\\mapsto\\text{\"erkenne\"}),(182\\mapsto\\text{\"was\"}),(183\\mapsto\\text{\"die\"}),(184\\mapsto\\text{\"Welt\"}),(185\\mapsto\\text{\"Im\"}),(186\\mapsto\\text{\"Innersten\"}),(187\\mapsto\\text{\"zusammenhält\"}),(188\\mapsto\\text{\"Schau\"}),(189\\mapsto\\text{\"alle\"}),(190\\mapsto\\text{\"Wirkenskraft\"}),(191\\mapsto\\text{\"und\"}),(192\\mapsto\\text{\"Samen\"}),(193\\mapsto\\text{\"Und\"}),(194\\mapsto\\text{\"tu\"}),(195\\mapsto\\text{\"nicht\"}),(196\\mapsto\\text{\"mehr\"}),(197\\mapsto\\text{\"in\"}),(198\\mapsto\\text{\"Worten\"}),(199\\mapsto\\text{\"kramen\"})\\}$" + ], + "text/plain": [ + "{(1↦\"FAUST\"),(2↦\"Habe\"),(3↦\"nun\"),(4↦\"ach\"),(5↦\"Philosophie\"),(6↦\"Juristerei\"),(7↦\"und\"),(8↦\"Medizin\"),(9↦\"Und\"),(10↦\"leider\"),(11↦\"auch\"),(12↦\"Theologie\"),(13↦\"Durchaus\"),(14↦\"studiert\"),(15↦\"mit\"),(16↦\"heißem\"),(17↦\"Bemühn\"),(18↦\"Da\"),(19↦\"steh\"),(20↦\"ich\"),(21↦\"nun\"),(22↦\"ich\"),(23↦\"armer\"),(24↦\"Tor\"),(25↦\"Und\"),(26↦\"bin\"),(27↦\"so\"),(28↦\"klug\"),(29↦\"als\"),(30↦\"wie\"),(31↦\"zuvor\"),(32↦\"Heiße\"),(33↦\"Magister\"),(34↦\"heiße\"),(35↦\"Doktor\"),(36↦\"gar\"),(37↦\"Und\"),(38↦\"ziehe\"),(39↦\"schon\"),(40↦\"an\"),(41↦\"die\"),(42↦\"zehen\"),(43↦\"Jahr\"),(44↦\"Herauf\"),(45↦\"herab\"),(46↦\"und\"),(47↦\"quer\"),(48↦\"und\"),(49↦\"krumm\"),(50↦\"Meine\"),(51↦\"Schüler\"),(52↦\"an\"),(53↦\"der\"),(54↦\"Nase\"),(55↦\"herum\"),(56↦\"Und\"),(57↦\"sehe\"),(58↦\"daß\"),(59↦\"wir\"),(60↦\"nichts\"),(61↦\"wissen\"),(62↦\"können\"),(63↦\"Das\"),(64↦\"will\"),(65↦\"mir\"),(66↦\"schier\"),(67↦\"das\"),(68↦\"Herz\"),(69↦\"verbrennen\"),(70↦\"Zwar\"),(71↦\"bin\"),(72↦\"ich\"),(73↦\"gescheiter\"),(74↦\"als\"),(75↦\"all\"),(76↦\"die\"),(77↦\"Laffen\"),(78↦\"Doktoren\"),(79↦\"Magister\"),(80↦\"Schreiber\"),(81↦\"und\"),(82↦\"Pfaffen\"),(83↦\"Mich\"),(84↦\"plagen\"),(85↦\"keine\"),(86↦\"Skrupel\"),(87↦\"noch\"),(88↦\"Zweifel\"),(89↦\"Fürchte\"),(90↦\"mich\"),(91↦\"weder\"),(92↦\"vor\"),(93↦\"Hölle\"),(94↦\"noch\"),(95↦\"Teufel\"),(96↦\"Dafür\"),(97↦\"ist\"),(98↦\"mir\"),(99↦\"auch\"),(100↦\"alle\"),(101↦\"Freud\"),(102↦\"entrissen\"),(103↦\"Bilde\"),(104↦\"mir\"),(105↦\"nicht\"),(106↦\"ein\"),(107↦\"was\"),(108↦\"Rechts\"),(109↦\"zu\"),(110↦\"wissen\"),(111↦\"Bilde\"),(112↦\"mir\"),(113↦\"nicht\"),(114↦\"ein\"),(115↦\"ich\"),(116↦\"könnte\"),(117↦\"was\"),(118↦\"lehren\"),(119↦\"Die\"),(120↦\"Menschen\"),(121↦\"zu\"),(122↦\"bessern\"),(123↦\"und\"),(124↦\"zu\"),(125↦\"bekehren\"),(126↦\"Auch\"),(127↦\"hab\"),(128↦\"ich\"),(129↦\"weder\"),(130↦\"Gut\"),(131↦\"noch\"),(132↦\"Geld\"),(133↦\"Noch\"),(134↦\"Ehr\"),(135↦\"und\"),(136↦\"Herrlichkeit\"),(137↦\"der\"),(138↦\"Welt\"),(139↦\"Es\"),(140↦\"möchte\"),(141↦\"kein\"),(142↦\"Hund\"),(143↦\"so\"),(144↦\"länger\"),(145↦\"leben\"),(146↦\"Drum\"),(147↦\"hab\"),(148↦\"ich\"),(149↦\"mich\"),(150↦\"der\"),(151↦\"Magie\"),(152↦\"ergeben\"),(153↦\"Ob\"),(154↦\"mir\"),(155↦\"durch\"),(156↦\"Geistes\"),(157↦\"Kraft\"),(158↦\"und\"),(159↦\"Mund\"),(160↦\"Nicht\"),(161↦\"manch\"),(162↦\"Geheimnis\"),(163↦\"würde\"),(164↦\"kund\"),(165↦\"Daß\"),(166↦\"ich\"),(167↦\"nicht\"),(168↦\"mehr\"),(169↦\"mit\"),(170↦\"saurem\"),(171↦\"Schweiß\"),(172↦\"Zu\"),(173↦\"sagen\"),(174↦\"brauche\"),(175↦\"was\"),(176↦\"ich\"),(177↦\"nicht\"),(178↦\"weiß\"),(179↦\"Daß\"),(180↦\"ich\"),(181↦\"erkenne\"),(182↦\"was\"),(183↦\"die\"),(184↦\"Welt\"),(185↦\"Im\"),(186↦\"Innersten\"),(187↦\"zusammenhält\"),(188↦\"Schau\"),(189↦\"alle\"),(190↦\"Wirkenskraft\"),(191↦\"und\"),(192↦\"Samen\"),(193↦\"Und\"),(194↦\"tu\"),(195↦\"nicht\"),(196↦\"mehr\"),(197↦\"in\"),(198↦\"Worten\"),(199↦\"kramen\")}" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - ":unlet txt" + "REGEX_SEARCH_ALL(txt,\"\\w+\")" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{\\text{\"Auch\"},\\text{\"Bemühn\"},\\text{\"Bilde\"},\\text{\"Da\"},\\text{\"Dafür\"},\\text{\"Das\"},\\text{\"Daß\"},\\text{\"Die\"},\\text{\"Doktor\"},\\text{\"Doktoren\"},\\text{\"Drum\"},\\text{\"Durchaus\"},\\text{\"Ehr\"},\\text{\"Es\"},\\text{\"FAUST\"},\\text{\"Freud\"},\\text{\"Fürchte\"},\\text{\"Geheimnis\"},\\text{\"Geistes\"},\\text{\"Geld\"},\\text{\"Gut\"},\\text{\"Habe\"},\\text{\"Heiße\"},\\text{\"Herauf\"},\\text{\"Herrlichkeit\"},\\text{\"Herz\"},\\text{\"Hund\"},\\text{\"Hölle\"},\\text{\"Im\"},\\text{\"Innersten\"},\\text{\"Jahr\"},\\text{\"Juristerei\"},\\text{\"Kraft\"},\\text{\"Laffen\"},\\text{\"Magie\"},\\text{\"Magister\"},\\text{\"Medizin\"},\\text{\"Meine\"},\\text{\"Menschen\"},\\text{\"Mich\"},\\text{\"Mund\"},\\text{\"Nase\"},\\text{\"Nicht\"},\\text{\"Noch\"},\\text{\"Ob\"},\\text{\"Pfaffen\"},\\text{\"Philosophie\"},\\text{\"Rechts\"},\\text{\"Samen\"},\\text{\"Schau\"},\\text{\"Schreiber\"},\\text{\"Schweiß\"},\\text{\"Schüler\"},\\text{\"Skrupel\"},\\text{\"Teufel\"},\\text{\"Theologie\"},\\text{\"Tor\"},\\text{\"Und\"},\\text{\"Welt\"},\\text{\"Wirkenskraft\"},\\text{\"Worten\"},\\text{\"Zu\"},\\text{\"Zwar\"},\\text{\"Zweifel\"},\\text{\"ach\"},\\text{\"all\"},\\text{\"alle\"},\\text{\"als\"},\\text{\"an\"},\\text{\"armer\"},\\text{\"auch\"},\\text{\"bekehren\"},\\text{\"bessern\"},\\text{\"bin\"},\\text{\"brauche\"},\\text{\"das\"},\\text{\"daß\"},\\text{\"der\"},\\text{\"die\"},\\text{\"durch\"},\\text{\"ein\"},\\text{\"entrissen\"},\\text{\"ergeben\"},\\text{\"erkenne\"},\\text{\"gar\"},\\text{\"gescheiter\"},\\text{\"hab\"},\\text{\"heiße\"},\\text{\"heißem\"},\\text{\"herab\"},\\text{\"herum\"},\\text{\"ich\"},\\text{\"in\"},\\text{\"ist\"},\\text{\"kein\"},\\text{\"keine\"},\\text{\"klug\"},\\text{\"kramen\"},\\text{\"krumm\"},\\text{\"kund\"},\\text{\"können\"},\\text{\"könnte\"},\\text{\"leben\"},\\text{\"lehren\"},\\text{\"leider\"},\\text{\"länger\"},\\text{\"manch\"},\\text{\"mehr\"},\\text{\"mich\"},\\text{\"mir\"},\\text{\"mit\"},\\text{\"möchte\"},\\text{\"nicht\"},\\text{\"nichts\"},\\text{\"noch\"},\\text{\"nun\"},\\text{\"plagen\"},\\text{\"quer\"},\\text{\"sagen\"},\\text{\"saurem\"},\\text{\"schier\"},\\text{\"schon\"},\\text{\"sehe\"},\\text{\"so\"},\\text{\"steh\"},\\text{\"studiert\"},\\text{\"tu\"},\\text{\"und\"},\\text{\"verbrennen\"},\\text{\"vor\"},\\text{\"was\"},\\text{\"weder\"},\\text{\"weiß\"},\\text{\"wie\"},\\text{\"will\"},\\text{\"wir\"},\\text{\"wissen\"},\\text{\"würde\"},\\text{\"zehen\"},\\text{\"ziehe\"},\\text{\"zu\"},\\text{\"zusammenhält\"},\\text{\"zuvor\"}\\}$" + ], + "text/plain": [ + "{\"Auch\",\"Bemühn\",\"Bilde\",\"Da\",\"Dafür\",\"Das\",\"Daß\",\"Die\",\"Doktor\",\"Doktoren\",\"Drum\",\"Durchaus\",\"Ehr\",\"Es\",\"FAUST\",\"Freud\",\"Fürchte\",\"Geheimnis\",\"Geistes\",\"Geld\",\"Gut\",\"Habe\",\"Heiße\",\"Herauf\",\"Herrlichkeit\",\"Herz\",\"Hund\",\"Hölle\",\"Im\",\"Innersten\",\"Jahr\",\"Juristerei\",\"Kraft\",\"Laffen\",\"Magie\",\"Magister\",\"Medizin\",\"Meine\",\"Menschen\",\"Mich\",\"Mund\",\"Nase\",\"Nicht\",\"Noch\",\"Ob\",\"Pfaffen\",\"Philosophie\",\"Rechts\",\"Samen\",\"Schau\",\"Schreiber\",\"Schweiß\",\"Schüler\",\"Skrupel\",\"Teufel\",\"Theologie\",\"Tor\",\"Und\",\"Welt\",\"Wirkenskraft\",\"Worten\",\"Zu\",\"Zwar\",\"Zweifel\",\"ach\",\"all\",\"alle\",\"als\",\"an\",\"armer\",\"auch\",\"bekehren\",\"bessern\",\"bin\",\"brauche\",\"das\",\"daß\",\"der\",\"die\",\"durch\",\"ein\",\"entrissen\",\"ergeben\",\"erkenne\",\"gar\",\"gescheiter\",\"hab\",\"heiße\",\"heißem\",\"herab\",\"herum\",\"ich\",\"in\",\"ist\",\"kein\",\"keine\",\"klug\",\"kramen\",\"krumm\",\"kund\",\"können\",\"könnte\",\"leben\",\"lehren\",\"leider\",\"länger\",\"manch\",\"mehr\",\"mich\",\"mir\",\"mit\",\"möchte\",\"nicht\",\"nichts\",\"noch\",\"nun\",\"plagen\",\"quer\",\"sagen\",\"saurem\",\"schier\",\"schon\",\"sehe\",\"so\",\"steh\",\"studiert\",\"tu\",\"und\",\"verbrennen\",\"vor\",\"was\",\"weder\",\"weiß\",\"wie\",\"will\",\"wir\",\"wissen\",\"würde\",\"zehen\",\"ziehe\",\"zu\",\"zusammenhält\",\"zuvor\"}" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ran(REGEX_SEARCH_ALL(txt,\"\\w+\"))" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{(1\\mapsto\\text{\"\\nFAUST\"})\\}$" + ], + "text/plain": [ + "{(1↦\"\\nFAUST\")}" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "REGEX_SEARCH_ALL(txt,\"\\n\\w+\")" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{(1\\mapsto\\text{\"\\nFAUST\"}),(2\\mapsto\\text{\"\\n Habe\"}),(3\\mapsto\\text{\"\\n Juristerei\"}),(4\\mapsto\\text{\"\\n Und\"}),(5\\mapsto\\text{\"\\n Durchaus\"}),(6\\mapsto\\text{\"\\n Da\"}),(7\\mapsto\\text{\"\\n Und\"}),(8\\mapsto\\text{\"\\n Heiße\"}),(9\\mapsto\\text{\"\\n Und\"}),(10\\mapsto\\text{\"\\n Herauf\"}),(11\\mapsto\\text{\"\\n Meine\"}),(12\\mapsto\\text{\"\\n Und\"}),(13\\mapsto\\text{\"\\n Das\"}),(14\\mapsto\\text{\"\\n Zwar\"}),(15\\mapsto\\text{\"\\n Doktoren\"}),(16\\mapsto\\text{\"\\n Mich\"}),(17\\mapsto\\text{\"\\n Fürchte\"}),(18\\mapsto\\text{\"\\n Dafür\"}),(19\\mapsto\\text{\"\\n Bilde\"}),(20\\mapsto\\text{\"\\n Bilde\"}),(21\\mapsto\\text{\"\\n Die\"}),(22\\mapsto\\text{\"\\n Auch\"}),(23\\mapsto\\text{\"\\n Noch\"}),(24\\mapsto\\text{\"\\n Es\"}),(25\\mapsto\\text{\"\\n Drum\"}),(26\\mapsto\\text{\"\\n Ob\"}),(27\\mapsto\\text{\"\\n Nicht\"}),(28\\mapsto\\text{\"\\n Daß\"}),(29\\mapsto\\text{\"\\n Zu\"}),(30\\mapsto\\text{\"\\n Daß\"}),(31\\mapsto\\text{\"\\n Im\"}),(32\\mapsto\\text{\"\\n Schau\"}),(33\\mapsto\\text{\"\\n Und\"})\\}$" + ], + "text/plain": [ + "{(1↦\"\\nFAUST\"),(2↦\"\\n Habe\"),(3↦\"\\n Juristerei\"),(4↦\"\\n Und\"),(5↦\"\\n Durchaus\"),(6↦\"\\n Da\"),(7↦\"\\n Und\"),(8↦\"\\n Heiße\"),(9↦\"\\n Und\"),(10↦\"\\n Herauf\"),(11↦\"\\n Meine\"),(12↦\"\\n Und\"),(13↦\"\\n Das\"),(14↦\"\\n Zwar\"),(15↦\"\\n Doktoren\"),(16↦\"\\n Mich\"),(17↦\"\\n Fürchte\"),(18↦\"\\n Dafür\"),(19↦\"\\n Bilde\"),(20↦\"\\n Bilde\"),(21↦\"\\n Die\"),(22↦\"\\n Auch\"),(23↦\"\\n Noch\"),(24↦\"\\n Es\"),(25↦\"\\n Drum\"),(26↦\"\\n Ob\"),(27↦\"\\n Nicht\"),(28↦\"\\n Daß\"),(29↦\"\\n Zu\"),(30↦\"\\n Daß\"),(31↦\"\\n Im\"),(32↦\"\\n Schau\"),(33↦\"\\n Und\")}" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "REGEX_SEARCH_ALL(txt,\"\\n\\s*\\w+\")" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\text{\" \\npublic class HelloWorld {\\n public static void main(String[] args) {\\n System.out.println(\\\"Hello, World\\\");\\n int res1 = 2*3;\\n System.out.println(res);\\n }\\n}\\n\"}$" + ], + "text/plain": [ + "\" \\npublic class HelloWorld {\\n public static void main(String[] args) {\\n System.out.println(\\\"Hello, World\\\");\\n int res1 = 2*3;\\n System.out.println(res);\\n }\\n}\\n\"" + ] + }, + "execution_count": 37, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + ":let jt ''' \n", + "public class HelloWorld {\n", + " public static void main(String[] args) {\n", + " System.out.println(\"Hello, World\");\n", + " int res1 = 22*33;\n", + " System.out.println(res);\n", + " }\n", + "}\n", + "'''" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\text{\"\\b[A-Za-z_][A-Za-z0-9_]*\"}$" + ], + "text/plain": [ + "\"\\b[A-Za-z_][A-Za-z0-9_]*\"" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + ":let ID \"\\b[A-Za-z_][A-Za-z0-9_]*\"" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\text{\"\\b[0-9]+\"}$" + ], + "text/plain": [ + "\"\\b[0-9]+\"" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + ":let Int \"\\b[0-9]+\"" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\text{\"\\b([A-Za-z_][A-Za-z0-9_]*)(\\.([A-Za-z_][A-Za-z0-9_]*))+\"}$" + ], + "text/plain": [ + "\"\\b([A-Za-z_][A-Za-z0-9_]*)(\\.([A-Za-z_][A-Za-z0-9_]*))+\"" + ] + }, + "execution_count": 45, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + ":let ComposedID \"\\b([A-Za-z_][A-Za-z0-9_]*)(\\.([A-Za-z_][A-Za-z0-9_]*))+\"" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{(1\\mapsto\\text{\"public\"}),(2\\mapsto\\text{\"class\"}),(3\\mapsto\\text{\"HelloWorld\"}),(4\\mapsto\\text{\"public\"}),(5\\mapsto\\text{\"static\"}),(6\\mapsto\\text{\"void\"}),(7\\mapsto\\text{\"main\"}),(8\\mapsto\\text{\"String\"}),(9\\mapsto\\text{\"args\"}),(10\\mapsto\\text{\"System\"}),(11\\mapsto\\text{\"out\"}),(12\\mapsto\\text{\"println\"}),(13\\mapsto\\text{\"Hello\"}),(14\\mapsto\\text{\"World\"}),(15\\mapsto\\text{\"int\"}),(16\\mapsto\\text{\"res1\"}),(17\\mapsto\\text{\"System\"}),(18\\mapsto\\text{\"out\"}),(19\\mapsto\\text{\"println\"}),(20\\mapsto\\text{\"res\"})\\}$" + ], + "text/plain": [ + "{(1↦\"public\"),(2↦\"class\"),(3↦\"HelloWorld\"),(4↦\"public\"),(5↦\"static\"),(6↦\"void\"),(7↦\"main\"),(8↦\"String\"),(9↦\"args\"),(10↦\"System\"),(11↦\"out\"),(12↦\"println\"),(13↦\"Hello\"),(14↦\"World\"),(15↦\"int\"),(16↦\"res1\"),(17↦\"System\"),(18↦\"out\"),(19↦\"println\"),(20↦\"res\")}" + ] + }, + "execution_count": 46, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "REGEX_SEARCH_ALL(jt,ID)" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{(1\\mapsto\\text{\"2\"}),(2\\mapsto\\text{\"3\"})\\}$" + ], + "text/plain": [ + "{(1↦\"2\"),(2↦\"3\")}" + ] + }, + "execution_count": 47, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "REGEX_SEARCH_ALL(jt,Int)" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "$\\{(1\\mapsto\\text{\"System.out.println\"}),(2\\mapsto\\text{\"System.out.println\"})\\}$" + ], + "text/plain": [ + "{(1↦\"System.out.println\"),(2↦\"System.out.println\")}" + ] + }, + "execution_count": 48, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "REGEX_SEARCH_ALL(jt,ComposedID)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Zusammenfassung\n", + "\n", + "Reguläre Ausdrücke können sehr nützlich sein.\n", + "Sie sind sehr mächtig, aber wir werden sehen, dass sie auch Grenzen haben.\n", + "\n", + "Sie finden Verwendung\n", + " * im Compilerbau (Tokenklassen zu definieren)\n", + " * in Editoren und IDEs\n", + " - Syntaxhighlighting, fortgeschrittene Suche (und Ersetzen)\n", + " * auf der Kommandozeile (grep) und in Programmen\n", + " - Verarbeiten von Log-Dateien, Einlesen oder Validierung von Daten, ...\n", + "\n", + "Es gibt viele Bibliotheken und Bücher über reguläre Ausdrücke, zum Beispiel:\n", + "\n", + "\n", + "\n", + "Es gibt auch diesen berühmten Comic von xkcd:\n", + "\n", + "" ] }, { -- GitLab