Flex小工具: 匹配String

Categories: Flex; Tagged with: ; @ October 23rd, 2011 16:00

需求

分别有两列数据, A列作为数据源, B列中数据都来自于A列. 现在需要验证B列中的数据是否都能在A列中匹配到相同的数据.

image

工具地址

http://liguoliang.com/pub/utils/StringMatcher/StringMatcher.html

image

核心代码:

var sourceArray:Array = strSource.split("\n"); // Get array from String;

/** * Convert array to Map, array value as the key, and the total nuber of the same value in the array as the value. */ private static function convertArrayToMap(array:Array):Object { var map:Object = new Object(); for each (var str:String in array) { var value:int = map[str] == null ? 0 : map[str]; if(value < 1) { map[str] = 1; // init count; }else { map[str] = value + 1; // Add one } } return map; }

<->



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.