We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 66e1074 commit a78ffa1Copy full SHA for a78ffa1
1 file changed
comment_spell_check/utils/url_remove.py
@@ -0,0 +1,22 @@
1
+#! /usr/bin/env python
2
+
3
+"""Module to remove URLs from a string."""
4
5
+import re
6
7
8
+def remove_urls(text):
9
+ """
10
+ Removes URLs from a string using a regular expression.
11
12
+ Args:
13
+ text: The input string.
14
15
+ Returns:
16
+ The string with URLs removed.
17
18
+ url_pattern = re.compile(
19
+ r"(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&\'\(\)\*\+,;=.]+",
20
+ re.IGNORECASE,
21
+ )
22
+ return url_pattern.sub("", text)
0 commit comments