ActionScript 3 关闭htmlText标记函数 - 如果你补间htmlText就很有用

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ActionScript 3 关闭htmlText标记函数 - 如果你补间htmlText就很有用相关的知识,希望对你有一定的参考价值。

public static function close_dangling_tags(str:String):String {
			var open_tags:Array = str.match(/<[a-z]+( .*)?(?!\/)>/img).map(function(e:*,i:int,arr:Array):String{return e.substr(1,e.length-2) });
			var closed_tags:Array = str.match(/<\/[a-z]+>/img).map(function(e:*,i:int,arr:Array):String{return e.substr(1,e.length-2) });
			if (open_tags.length == closed_tags.length){
				return str;
			}
			var tag_heap:Array = new Array();
			for each(var tag:String in open_tags) {
				tag_heap.push(tag);
				while (tag_heap.length && closed_tags.length && ArrayTools.last(tag_heap) == ArrayTools.first(closed_tags)) {
					tag_heap.pop();
					closed_tags.shift();
				}
			}
			return str+tag_heap.reverse().map(function(e:*,i:int,arr:Array):String{return '</'+e+'>'}).join('');
		}

以上是关于ActionScript 3 关闭htmlText标记函数 - 如果你补间htmlText就很有用的主要内容,如果未能解决你的问题,请参考以下文章

什么 IDE 可用于 ActionScript 3 编码? [关闭]

我应该学习 Actionscript 3 和 Javascript 来制作网页游戏吗? [关闭]

使用 Actionscript 3 连接到数据库 [关闭]

如何解决 ActionScript 3 (AS3) 中的关闭问题

ActionScript 3 AIR:在应用程序退出之前关闭所有可能的Windows

调试 Flash ActionScript 3 (AS3) 的最佳工具 [关闭]