Hey beginner5,
Glad it helped you out! 
But yeah, it of course could & should be improved (regex, s1=s2..). 
Btw, naaaise player stats grabber!
Edit:
Modified the AllBetween function a bit.. Added support for s1 = s2, but... There needs to be exact amount of start and end 'brackets', in order to get results correctly (with s1=s2).. :\ This is something where regexes will do a lot better job, for sure..
Here is the improved AllBetween:
Code:
function AllBetween2(s1, s2, s: string): TStringArray;
var
sL, s1L, s2L, old_start, start, finish: Integer;
str: string;
begin
s1L := Length(s1);
s2L := Length(s2);
sL := Length(s);
if (s1 = '') or (s2 = '') or (s = '') or (s1L >= sL) or (s2L >= sL) or ((s1L + s2L) > sL) then
Exit;
start := PosEx(s1, s, 1)
repeat
if finish > 0 then
start := PosEx(s1, s, (finish + s2L));
if start > 0 then
begin
finish := PosEx(s2, s, start + 1);
if finish <= 0 then
Break;
repeat
old_start := start;
start := PosEx(s1, s, old_start + s1L);
until (start >= finish) or (start <= 0);
start := old_start;
if str <> '' then
str := str + '{ab_NS}';
str := str + Between(s1, s2, Copy(s, start, s2L + (finish - start)));
end else
Break;
until False;
if str <> '' then
Result := Explode('{ab_NS}', str);
str := '';
end;
And a small example/test script:
Code:
function AllBetween2(s1, s2, s: string): TStringArray;
var
sL, s1L, s2L, old_start, start, finish: Integer;
str: string;
begin
s1L := Length(s1);
s2L := Length(s2);
sL := Length(s);
if (s1 = '') or (s2 = '') or (s = '') or (s1L >= sL) or (s2L >= sL) or ((s1L + s2L) > sL) then
Exit;
start := PosEx(s1, s, 1)
repeat
if finish > 0 then
start := PosEx(s1, s, (finish + s2L));
if start > 0 then
begin
finish := PosEx(s2, s, start + 1);
if finish <= 0 then
Break;
repeat
old_start := start;
start := PosEx(s1, s, old_start + s1L);
until (start >= finish) or (start <= 0);
start := old_start;
if str <> '' then
str := str + '{ab_NS}';
str := str + Between(s1, s2, Copy(s, start, s2L + (finish - start)));
end else
Break;
until False;
if str <> '' then
Result := Explode('{ab_NS}', str);
str := '';
end;
var
s: string;
TSA: TStringArray;
h, i: Integer;
begin
s := '"user1", "user2", "user3", "user4"';
TSA := AllBetween2('"', '"', s);
h := High(TSA);
for i := 0 to h do
WriteLn(TSA[i]);
SetLength(TSA, 0);
end.
Small forum widget, that I made for fun (active users browsing SRL-forums...), using AllBetween[2] and TSAToParts functions:
Code:
function TSAToParts(TSA: TStringArray; partSize: Integer): array of TStringArray;
var
i, i2, r, h, d: Integer;
begin
h := High(TSA);
if (h >= 0) and (partSize > 0) then
if partSize <= h then
begin
Inc(h);
r := (h div partSize);
if (r * partSize) < h then
Inc(r);
SetLength(Result, r);
for i := 0 to (r - 1) do
for i2 := 0 to (partSize - 1) do
begin
SetLength(Result[i], partSize);
if d < h then
begin
Result[i][i2] := TSA[d];
Inc(d);
end else
begin
SetLength(Result[i], i2);
Exit;
end;
end;
end else
Result := [TSA];
end;
function AllBetween(s1, s2, s: string): TStringArray;
var
sL, s1L, s2L, old_start, start, finish: Integer;
str: string;
begin
s1L := Length(s1);
s2L := Length(s2);
sL := Length(s);
if (s1 = '') or (s2 = '') or (s = '') or (s1L >= sL) or (s2L >= sL) or ((s1L + s2L) > sL) then
Exit;
start := PosEx(s1, s, 1)
repeat
if finish > 0 then
start := PosEx(s1, s, (finish + s2L));
if start > 0 then
begin
finish := PosEx(s2, s, start + 1);
if finish <= 0 then
Break;
repeat
old_start := start;
start := PosEx(s1, s, old_start + s1L);
until (start >= finish) or (start <= 0);
start := old_start;
if str <> '' then
str := str + '{ab_NS}';
str := str + Between(s1, s2, Copy(s, start, s2L + (finish - start)));
end else
Break;
until False;
if str <> '' then
Result := Explode('{ab_NS}', str);
str := '';
end;
var
TSA: TStringArray;
h, h2, i, i2: Integer;
s: string;
T2DSA: array of TStringArray;
begin
ClearDebug;
s := Between('<td class="alt1"><span class="smallfont"> <a href="http://villavu.com/forum/member.php', ' </tr>', GetPage('http://villavu.com/'));
TSA := AllBetween('">', '</span></a>', s);
s := '';
T2DSA := TSAToParts(TSA, 9);
WriteLn('List of Active Members @SRL-Forums [' + IntToStr(High(TSA) + 1) + ']:');
SetLength(TSA, 0);
h := High(T2DSA);
for i := 0 to h do
begin
h2 := High(T2DSA[i]);
for i2 := 0 to h2 do
s := s + T2DSA[i][i2] + ', ';
SetLength(T2DSA[i], 0);
if (i = h) then
WriteLn(Copy(s, 0, Length(s) - 2) + '.')
else
WriteLn(s);
s := '';
end;
SetLength(T2DSA, 0);
end.
Feel free to use!