This commit is contained in:
Yavuz Sava 2024-12-30 16:04:05 +03:00
parent 5caeef0bca
commit 6837e4f0be

View File

@ -444,7 +444,10 @@
" return \"{} {}\".format(result[2], result[1])\n",
"\n",
"name=rearrange_name(\"Kennedy, John F.\")\n",
"print(name)"
"print(name)\n",
"\n",
"# Output:\n",
"# John F. Kennedy"
]
},
{
@ -463,7 +466,19 @@
"import re\n",
"print(re.search(r\"[a-zA-Z]{5}\", \"a ghost\"))\n",
"print(re.search(r\"[a-zA-Z]{5}\", \"a scary ghost appeared\"))\n",
"print(re.findall(r\"[a-zA-Z]{5}\", \"a scary ghost appeared\"))"
"print(re.findall(r\"[a-zA-Z]{5}\", \"a scary ghost appeared\"))\n",
"re.findall(r\"\\b[a-zA-Z]{5}\\b\", \"A scary ghost appeared\")\n",
"print(re.findall(r\"\\w{5,10}\", \"I really like strawberries\"))\n",
"print(re.findall(r\"\\w{5,}\", \"I really like strawberries\"))\n",
"print(re.search(r\"s\\w{,20}\", \"I really like strawberries\"))\n",
"\n",
"# Output:\n",
"# <re.Match object; span=(2, 7), match='ghost'>\n",
"# <re.Match object; span=(2, 7), match='scary'>\n",
"# ['scary', 'ghost', 'appea']\n",
"# ['really', 'strawberri']\n",
"# ['really', 'strawberries']\n",
"# <re.Match object; span=(14, 26), match='strawberries'>"
]
}
],