I had the exact same experience. Writing code for existing popular problems is phenomenal. But when you diverge slightly, it breaks down.
I asked it to write a regex which finds all html tags that has a specific class name, but does not contain another specific class name. I assume this problem has been tackled many times by scores of developers. It had outputted an excellent regex.
I asked it to ignore texts in inline script (such as event handlers), and it presented an invalid regex.
I tried to point out the problem but it just went into a loop of bad regex code.