Return part of a string with variable length
2
votes
2
answers
538
views
I have data in a table column like below:
host=0.0.0.0 port=5432 dbname=database_name user=pglogicaluser
host=0.0.0.0 port=5432 dbname=database_name2 user=pglogicaluser
I want to write a query to get the database names only like below:
database_name
database_name2
I could come up with something like:
select substring(column_name, '.+dbname=(.*)$') from table_name;
However, I couldn't figure how to stop the extraction before the user
keyword starts.
Asked by Sayad Xiarkakh
(532 rep)
Mar 21, 2022, 06:28 PM
Last activity: Sep 3, 2023, 04:21 PM
Last activity: Sep 3, 2023, 04:21 PM