{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Original string:

Contents :

Python ExamplesEven More Examples\n", "Urls: ['https://w3resource.com', 'http://github.com']\n" ] } ], "source": [ "# Write a Python program to find urls in a string.\n", "# \n", "# Input\n", "# '

Contents :

Python ExamplesEven More Examples'\n", "# \n", "# Output\n", "# Urls: ['https://w3resource.com', 'http://github.com']\n", "\n", "import re\n", "text = '

Contents :

Python ExamplesEven More Examples'\n", "urls = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', text)\n", "print(\"Original string: \",text)\n", "print(\"Urls: \",urls)" ] } ], "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 }