(no title)
gbro3n | 2 years ago
"PostgresSql": "Host=localhost;User ID=postgres;Password=xxxx;Database=test;Application Name=Test1234,Port=35432;Pooling=false;"
I selected User ID=, Host=, Application Name=, Password=
The results were pretty useless, using the literal inputs as pattern matches:
(User ID|Host|Application Name|Password)=([^;]) (User ID|Host|Application Name|Password)=([\w]) (User ID=)|(Host=)|(Application Name=)|(Password=) ([Uu]ser [Ii][Dd]=)|([Hh]ost=)|([Aa]pplication [Nn]ame=)|([Pp]assword=)
The following prompt given to Chat GPT 4 however:
> Write a regular expression to extract the property names from this PostgreSQL connection string: "PostgresSql": "Host=localhost;User ID=postgres;Password=xxxx;Database=test;Application Name=Test1234,Port=35432;Pooling=false;"
Yields the response with an explanation:
(?<=[^\\w])([A-Za-z ]+)(?==)
"This regular expression will match any sequence of alphabetic characters (upper or lower case) that are followed by an equal sign (=). The negative lookbehind (?<=[^\\w]) ensures that the property name is not preceded by another word character."
A quick test on regex101.com shows this works perfectly.
Sorry, don't like to be overly critical. Someone has attempted to solve a common problem for developers, but LLMs are going to blow applications like this away. And I think that Chat GPT at version 4 has become a truly useful tool.
I was interested to test this since I'd been writing a regular expression earlier in the day for a similar usecase, which I've written up here: https://journals.appsoftware.com/public/76/227/4221/blog/sof...
No comments yet.