By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
Help with an interesting Postgres question: Why isn't an Index Only Scan used on a partition accessed via the parent table?.
SELECT string, substring(string, '\d+\D?\M')
FROM (
VALUES
('FLAT 3, thanos house, nw1 6fs')
, ('FLAT 3B, thanos house, nw1 6fs')
, ('324, thanos house, nw1 6fs')
, ('APARTMENT 324, thanos house, nw1 6fs')
) tbl(string);
string | substring |
---|---|
FLAT 3, thanos house, nw1 6fs | 3 |
FLAT 3B, thanos house, nw1 6fs | 3B |
324, thanos house, nw1 6fs | 324 |
APARTMENT 324, thanos house, nw1 6fs | 324 |
SELECT 4