我有一个文件文本超过 1 000 000 行,以字符C开头,另一个以M开头 示例:
C9203007870000000000000006339912610971240095400111200469300000 16122011AMI 00000100010000315 080
C9203007870000000000000006339912610971240095400111200469300000 09122011B 590001000100000270016092100
M920300787000000000000000633991261097124009540011120046930000031122011JVJF004 10 N
M920300787000000000000000633991261097124009540011120046930000009122011DEQP003 10 N
M920300787000000000000000633991261097124009540011120046930000012122011ACQK001 10Z N
C9203007870000000000000006339912610971240095400111200469300000 24122011AMI 00000100010000315 080
C9203007870000000000000006339912610971240095400111200469300000 24122011AMI 00000100010000315 080
我只想将以字符M开头的行放入我的数组中 如何在拆分中添加: var pattern:RegExp = /^M/;
var mFileReference:FileReference;
var mArray:Array = new Array();
function onFileLoaded(event:Event):void
{
mFileReference = event.target as FileReference;
data = mFileReference["data"];
mArray = (data.toString()).split("\n");
}
我不想通过循环“因为”它需要大量时间和资源我想将 /^M/ 添加到我的拆分中是否可能?
for each (var s:String in mArray)
{
if (pattern.test(s)) {
values.push(s);
}
}
谢谢大家。