+function TWebModule1.scan(text: string): string;
+var
+ reg: TRegEx;
+ coll: TMatchCollection;
+ i, j: Integer;
+ s, t, str: string;
+begin
+ i := Request.QueryFields.Values['db'].ToInteger;
+ s := Request.ScriptName;
+ text := TNetEncoding.HTML.Encode(text);
+ str := TNetEncoding.HTML.Encode('>>');
+ reg := TRegEx.Create(str + '(\d+)');
+ coll := reg.Matches(text);
+ for j := coll.count - 1 downto 0 do
+ begin
+ Delete(text, coll[j].index, coll[j].Length);
+ t := Copy(coll[j].Value, Length(str) + 1, coll[j].Length);
+ result := Format
+ ('<a class=minpreview data-preview-url=%s/link?db=%d&num=%s href=%s/jump?db=%d&num=%s>>>%s</a>',
+ [s, i, t, s, i, t, t]);
+ Insert(result, text, coll[j].index);
+ end;
+ result := text;
+end;
+