Kaynağa Gözat

added stripTags string helper

Alexander Rose 5 yıl önce
ebeveyn
işleme
cdb698f0d1
1 değiştirilmiş dosya ile 5 ekleme ve 0 silme
  1. 5 0
      src/mol-util/string.ts

+ 5 - 0
src/mol-util/string.ts

@@ -73,4 +73,9 @@ export function trimCharEnd(str: string, char: string) {
     let end = str.length;
     while (end > 0 && str[end - 1] === char) --end;
     return (end < str.length) ? str.substring(0, end) : str;
+}
+
+/** Simple function to strip tags from a string */
+export function stripTags(str: string) {
+    return str.replace(/<\/?[^>]+>/g, '')
 }