-
Notifications
You must be signed in to change notification settings - Fork 1
/
replaceHTMLCodes.py
47 lines (40 loc) · 1.07 KB
/
replaceHTMLCodes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
class replaceHTMLCodes:
def __init__(self, text):
"""
Initialize the class
Parameters
----------
self : replaceHTMLCodes
The class itself
text : str
The text to replace the HTML codes in
Returns
-------
None
"""
self.text = text
def replaceAmpersandCodes(self):
"""
Replace HTML codes with their respective characters
Parameters
----------
self : replaceHTMLCodes
The class itself
Returns
-------
self.text : str
The text with the HTML codes replaced
"""
text = self.text
text = text.replace("&", "&")
text = text.replace("<", "<")
text = text.replace(">", ">")
text = text.replace(""", '"')
text = text.replace("©", "©")
text = text.replace("&", "&")
return text
def getText(self):
"""
Return the text
"""
return self.text