{ "cells": [ { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['quick', 'brown', 'jumps']\n" ] } ], "source": [ "# Write a Python program to find all five characters long word in a string.\n", "# Input\n", "# 'The quick brown fox jumps over the lazy dog.'\n", "# Output\n", "# ['quick', 'brown', 'jumps']\n", "\n", "import re\n", "text = 'The quick brown fox jumps over the lazy dog.'\n", "print(re.findall(r\"\\b\\w{5}\\b\", text))" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.1" } }, "nbformat": 4, "nbformat_minor": 2 }