SELECT 
     m.srce
    ,m.target
    ,m.regex->'regex'->>'function' func_name
    ,m.regex->'regex'->>'description' descr
    ,filter.v  filters
    ,defn.v->> 'field' result_key_name
    ,defn.v->> 'key' target_json_path
    ,defn.v->>'regex' regex_expression
    ,defn.v->> 'flag' regex_options_flag
    ,defn.v->>'map' map_intention
    ,defn.v->>'retain' retain_result
    ,defn.rn target_item_number
FROM 
    tps.map_rm m
    LEFT JOIN LATERAL jsonb_array_elements(m.regex->'regex'->'defn') WITH ORDINALITY defn(v, rn) ON true
    LEFT JOIN LATERAL jsonb_array_elements(m.regex->'regex'->'where') WITH ORDINALITY filter(v, rn) ON true
ORDER BY 
     m.srce
    ,m.target
    ,defn.rn
