# Replace URLs using Regex

> Replacing urls with regex is very easy.

- Canonical: https://preview.arshadmehmood.com/today-i-learned/python/replace-urls-with-regex/
- Section: python
- Author: Arshad Mehmood

Replacing urls with regex is very easy.

```python
import re
text = re.sub('http://\S+|https://\S+', '', textWithURLs)
```

