as去掉字符串中的重复字符

 1 package  antCodes
 2 {
 3     /**
 4      * ...
 5      * 去掉字符串中的重复字符
 6      * 
 7      * @author Dong
 8      */
 9     public class ToRepeat 
10     {
11         public var str:String = "";
12         public function ToRepeat() 
13         {
14             
15         }
16         
17         //去掉字符串中的重复字符
18         public function toRepeat(str:String):String {
19             var len:int = str.length;
20             var i:int = 1;
21             while (i < len) {
22                 if (this.str.match(str.charAt(i)) == null) {
23                     this.str = this.str + str.charAt(i);
24                     i++;
25                 }else {
26                     i++;
27                 }
28             }
29             return this.str;
30         }
31     }
32 
33 }
原文地址:https://www.cnblogs.com/finger/p/2438917.html