Last active
December 7, 2015 09:48
-
-
Save tingwei628/3600d927fb7b2a66baaf to your computer and use it in GitHub Desktop.
[JavaScript][ExtJS]如何將 ExtJS 的htmleditor 裡面的style 簡單化 (simplify the style inside the htmleditor)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
paste: { | |
element: 'inputEl', | |
fn: function(event, inputEl) { | |
var a = add_Content.getValue(); | |
//已過濾表格 儲存在var b | |
var b = a.replace(/((<td[^>]+)style=".*?">)/ig, function(x) { | |
return x = x.replace(/style=".*?"/, 'style="border:solid"'); | |
}); | |
//對非td 的style 改變,儲存在c | |
var c = b.replace(/((<[^td][^>]+)style=".*?">)/ig, function(y) { | |
y = y.replace(/style=".*?"/, 'style=""'); | |
return y; | |
}); | |
add_Content.setValue(c); | |
} | |
} |
同上, 但多了過濾" "
參考:http://stackoverflow.com/questions/1499889/remove-html-tags-in-javascript-with-regex
//s 是一連串的html
s.replace(/( |<([^>]*)>)/ig,'')
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
補充說明: 如何移除Html tag, 取得裡面的文字
(參考:http://stackoverflow.com/questions/11229831/regular-expression-to-remove-html-tags-from-a-string)
例如: