问题:需要获取字符串中的所有 st 。这样做,但在备忘录中只添加最后一个结果,即 st2。如何获得 st 和 st2 等?
const
pattern = '<h3 class=.*><a class=.*>([a-zA-Z0-9а-яА-Я]+)</a></h3>';
var
r: TRegExpr;
s: string;
begin
r:=TRegExpr.Create;
s:='<h3 class="yt-lockup-ellipsize"><a class="yt-uix-sessionlink yt-uix-tile-link result-item-translation-title"dir="ltr"title="Женщины"data-sessionlink="ei=CO_0s_S3oLECFQQZ3wodxl5sKw%3D%3D"href="/watch?v=E0MzksPjObU">st1</a></h3>';
s:=s + '<h3 class="yt-lockup-ellipsize"><a class="yt-uix-sessionlink yt-uix-tile-link result-item-translation-title"dir="ltr"title="Женщины"data-sessionlink="ei=CO_0s_S3oLECFQQZ3wodxl5sKw%3D%3D"href="/watch?v=E0MzksPjObU">st2</a></h3>';
r.Expression:=pattern;
if r.Exec(s) then
REPEAT
Memo2.Lines.Add(r.Match[1]);
UNTIL not r.ExecNext;