Open jonjensen opened 2 years ago
This is another possible solution:
WITH f(fields) AS (
SELECT *
FROM regexp_split_to_array('||121212^^^2^ID 1|676767||SELVA^KUMAR^^^^|19480203|M||B||123456 SAMPLE ROAD^^New York City^NY^12345^USA^H^^New York||123456-7890|||M|NON|4000|', '\|')
),
c(component) AS (
SELECT component
FROM f, regexp_split_to_array(fields[12], '\^') AS c(component)
)
SELECT component[1] AS address,
component[2] AS address2,
component[3] AS city,
component[4] AS state,
component[5] AS zip,
component[6] AS country
FROM c
@lveronese Very nice!
Comments for https://www.endpointdev.com/blog/2022/01/regex-group-quantifiers-postgresql/ by Selvakumar Arumugam
To enter a comment: