How can I improve this regex (?<=\/\/)(.*?)(?=\@) to extract the username:password from a postgresql connection string.
I want to extract this string db-admin-username@server:this-is-funny-passowrd/is-continuing= from this string postgresql://db-admin-username@server:this-is-funny-passowrd/[email protected]/dbname
It returns the wrong string in case the password or username contains @
It should extract anything between // and the last @ characters.
substring('postgresql://db-admin-username@server:this-is-funny-passowrd/[email protected]/dbname' from '//(.*)@')?SELECT regexp_matches(col, '//(.*)@')