{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[]\n"
     ]
    }
   ],
   "source": [
    "import re\n",
    "\n",
    "pattern = r'Car '\n",
    "text = r'''\n",
    "    Here is the car of the future! This car is the opposite of todays' cars; \n",
    "    today's cars are noisy and dirty, this one is silent and clean. \n",
    "    Today's cars have wheels, this one does not. It moves like a snail, but much faster than a snail !\n",
    "'''\n",
    "\n",
    "result = re.findall(pattern, text)\n",
    "print(result)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['2100']\n"
     ]
    }
   ],
   "source": [
    "import re\n",
    "\n",
    "pattern = r\"\\d{4}\"\n",
    "text = r'''\n",
    "     However you probably won't ever drive a \"snail car\", \n",
    "     even if you're under 20 today.\n",
    "     This, perhaps, is the car of the year 2100, \n",
    "     the car that your grandchildren will maybe drive.\n",
    "'''\n",
    "\n",
    "result = re.findall(pattern, text)\n",
    "print(result)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['aalaaeddein@gmail.com', 'Test.2@gmail.com', 'Test_1994@outlook.gov']\n"
     ]
    }
   ],
   "source": [
    "\n",
    "import re\n",
    "\n",
    "pattern = r'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}'\n",
    "text = r'''\n",
    "     Here is my email address: aalaaeddein@gmail.com\n",
    "I have another email address: Test.2@gmail.com\n",
    "Here is my Outlook email: Test_1994@outlook.gov\n",
    "'''\n",
    "\n",
    "result = re.findall(pattern, text)\n",
    "print(result)\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[' 78888222', ' 76 - 443 222', '(+961) 71 321123']\n"
     ]
    }
   ],
   "source": [
    "import re\n",
    "\n",
    "pattern = r\"\\(?\\+?\\d*\\)? *\\d\\d *-? *\\d\\d\\d *\\d\\d\\d\"\n",
    "text = r'''\n",
    "     Here is my phone number: 78888222\n",
    "I have another number: 76 - 443 222\n",
    "If you want to contact from outside Lebanon use this: (+961) 71 321123\n",
    "'''\n",
    "\n",
    "result = re.findall(pattern, text)\n",
    "print(result)\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['19.232.111.0', '19.1.9.8', '1.0.0.255', '1.55.90.190']\n"
     ]
    }
   ],
   "source": [
    "\n",
    "import re\n",
    "\n",
    "pattern = r\"(?:(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9][0-9])|(?:[0-9][0-9])|(?:[0-9]))\\.){3}(?:(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9][0-9])|(?:[0-9][0-9])|(?:[0-9])))\"\n",
    "text = r'''\n",
    "   19.232.111.0\n",
    "222.265.111.111\n",
    "132.1333.211.11\n",
    "19.1.9.8\n",
    "1.0.0.255\n",
    "1.55.90.190\n",
    "8.2.190\n",
    "'''\n",
    "\n",
    "result = re.findall(pattern, text)\n",
    "print(result)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "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.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
