PostgreSQL only selects the letters in the column

So I have this column that contains the street address and house number, and they are all stored in the same column.

For example: Boulevard 123

< p>Now I want to separate these letters from numbers, so I get “Boulevard” and “123” respectively through a select statement.

How can I do this with reg expressions?

Thanks in advance

One way is to use regexp_split_to_array

code>Split the value by spaces:

SELECT address_arr[1] AS streer_name, address_arr[2] AS street_number
FROM (SELECT REGEXP_SPLIT_TO_ARRY(address, '') AS address_arr
FROM my_table) t

So I have this column that contains the street address and house number, and they are all stored in the same column.

For example: Boulevard 123

Now I want to separate these letters from numbers, so I get "Boulevard" and "123" respectively through a select statement.

< p>How can I do this with reg expressions?

Thanks in advance

One way is to use regexp_split_to_array to split the value by spaces:

< /p>

SELECT address_arr[1] AS streer_name, address_arr[2] AS street_number
FROM (SELECT REGEXP_SPLIT_TO_ARRY(address, '') AS address_arr
FROM my_table) t

Leave a Comment

Your email address will not be published.