from typing import Optional
import re


def extract_url(text: str) -> Optional[str]:
    """Extracts url from text

    Parameters
    ----------
    text : str
        String from which url to be extracted.

    Returns
    -------
    Optional[str]
        Return url if present in the given string.
    """
    regex_extract = re.search("(?P<url>https?://[^\s]+)", text)
    return regex_extract.group("url") if regex_extract else None