Posted By

dhjapan on 12/20/07


Tagged

as


Versions (?)

strip HTML


 / Published in: ActionScript
 

Supprime les tags html d'un chaine de caractère

  1. // s : la chaine de caractère - tags : la liste des tags à supprimer
  2. private function stripHTML(s:String, tags:Array) {
  3. if(tags == undefined) tags = ["p","h1","h2","h3","h4","h5","h6","strong","em","abbr","acronym","address","bdo","blockquote","cite","q","code","ins","del","dfn","kbd","pre","samp","var","br","a","base","ul","ol","li","dl","dt","dd","table","tr","td","th","tbody","thead","tfoot","col","colgroup","caption","script","noscript","html","head","body","div","span","a","abbr","acronym","address","area","b","base","bdo","big","blockquote","body","br","button","caption","cite","code","col","colgroup","dd","del","dfn","div","dl","DOCTYPE","dt","em","fieldset","form","h1","h2","h3","h4","h5","andh6","head","html","hr","i","img","input","ins","kbd","label","legend","li","link","map","meta","noscript","object","ol","optgroup","option","p","param","pre","q","samp","script","select","small","span","strong","style","sub","sup","table","tbody","td","textarea","tfoot","th","thead","title","tr","tt","ul","var","DOCTYPE","title","link","meta","style","b","i","tt","sub","sup","big","small","hr"];
  4. for (var i = 0; i < tags.length; i++) {
  5. var tag:Array = ["<"+tags[i]">", "</"+tags[i]">", "<"+tags[i]"/>", "<"+tags[i]" />"];
  6. for (var j = 0; j<tag.length; j++) {
  7. var tmp = s.split(tag[j]);
  8. s = tmp.join(" ");
  9. }
  10. }
  11. return s;
  12. }
  13. //

Report this snippet  

You need to login to post a comment.