drop table if exists u cascade;
create table u (zielnummer integer);

drop table if exists b cascade;
create table b (btext text);

drop table if exists r cascade;
create table r (buchnummer integer);
create index r_buchnummer on r (buchnummer);

select u.zielnummer, gnummer.v
  from u
    left join b on b.btext ~ '^verr\. R(\d+)$'
    left join lateral (select regexp_replace (b.btext, 'verr\. R', '')::int v)
      as gnummer on true
    left join r on r.buchnummer = gnummer.v;

select u.zielnummer, gnummer.v
  from u
    left join b on b.btext ~ '^verr\. R(\d+)$'
    left join lateral (select regexp_replace (b.btext, 'verr\. R', '')::int v)
      as gnummer on true
    left join lateral (select * from r where buchnummer = gnummer.v)
      as r on true
