0

i have a html page , i use regex to remove all html tags from the page and extract the text using the below code.

var foo = loader.data.replace(/<.*?>/g, "");
var bar:Array = foo.split("Total");
foo = foo.split(bar[0]);
trace(foo);

And using the same code lines below the replace method i remove every string before the word "TOTAL". It does the job perfectly but now i want to apply and other split to get contents after "TOTAL" and remove the Content after "BYTES".

So when i try to split it up again with

var bar2:Array = foo.split("BYTES");
foo = foo.split(bar2[0]);

Flash returns a error saying SPLIT is a not a valid method :S I tried several other ways , ( REPLACE ) but still flash produces errors.

Can Anyone help me to get through this ? Thank you

4

1 回答 1

2

“.split()”是String的一种方法。当您完成以下作业时:

foo = foo.split(bar[0]);

foo 变成了一个数组,因此调用

var bar2:Array = foo.split("BYTES");

正在制作一个无效的数组(没有这种方法)

你想要的是这样的:

var foo = loader.data.replace(/<.*?>/g, "");
trace(foo);
var result = foo.split("Total")[1].split("BYTES")[0];
trace(result);
于 2013-03-07T08:06:56.953 回答