What's the #$d#$a main? LineSeparators might be \n?
$D = 0x0D (hex)
$A = 0x0A (hex)
$D$A = CRLF
Line separators:
If you only want to extract everything from '<div id="pagination"' to body '"</body>"' you can do it without regexp.
here is the function:
function ExtractStr(SourceStr, PrefixPattern, SuffixPattern: String): String;
var
p1, p2: Integer;
begin
Result := '';
p1 := Pos(PrefixPattern, SourceStr);
If p1 = 0 Then Exit;
p2 := Pos(SuffixPattern, SourceStr);
If p2 = 0 Then
p2 := Length(SourceStr);
Result := Copy(SourceStr, p1, p2 - p1 + Length(SuffixPattern));
end;
If you want to clear line separators from some string
Windows: '\r\n'
Mac (OS 9-): '\r'
Mac (OS 10+): '\n'
Unix/Linux: '\n'
you can make this function:
function ClearLineSeparators(SourceString: String): String;
begin
Result := StringReplace(SourceStr, #13, '', [rfReplaceAll]);
Result := StringReplace(Result, #10, '', [rfReplaceAll]);
end;
(There is a room for optimization, these functions can be done with only one pass from string using for loop)