File tree Expand file tree Collapse file tree 3 files changed +49
-0
lines changed
solution/1400-1499/1410.HTML Entity Parser Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -182,6 +182,24 @@ public:
182182};
183183```
184184
185+ ### **TypeScript**
186+
187+ ```ts
188+ function entityParser(text: string): string {
189+ const d: { [key: string]: string } = {
190+ '"': '"',
191+ ''': "'",
192+ '&': '&',
193+ '>': '>',
194+ '<': '<',
195+ '⁄': '/',
196+ };
197+
198+ const pattern = new RegExp(Object.keys(d).join('|'), 'g');
199+ return text.replace(pattern, match => d[match]);
200+ }
201+ ```
202+
185203### ** ...**
186204
187205```
Original file line number Diff line number Diff line change @@ -151,6 +151,24 @@ public:
151151};
152152```
153153
154+ ### **TypeScript**
155+
156+ ```ts
157+ function entityParser(text: string): string {
158+ const d: { [key: string]: string } = {
159+ '"': '"',
160+ ''': "'",
161+ '&': '&',
162+ '>': '>',
163+ '<': '<',
164+ '⁄': '/',
165+ };
166+
167+ const pattern = new RegExp(Object.keys(d).join('|'), 'g');
168+ return text.replace(pattern, match => d[match]);
169+ }
170+ ```
171+
154172### ** ...**
155173
156174```
Original file line number Diff line number Diff line change 1+ function entityParser ( text : string ) : string {
2+ const d : { [ key : string ] : string } = {
3+ '"' : '"' ,
4+ ''' : "'" ,
5+ '&' : '&' ,
6+ '>' : '>' ,
7+ '<' : '<' ,
8+ '⁄' : '/' ,
9+ } ;
10+
11+ const pattern = new RegExp ( Object . keys ( d ) . join ( '|' ) , 'g' ) ;
12+ return text . replace ( pattern , match => d [ match ] ) ;
13+ }
You can’t perform that action at this time.
0 commit comments