Re:Introducing ChatGPT Plus
by paulclinger on Wednesday February 01, 2023 @07:58PM
(#34620565)
Agree; the ChatGPT answer is not correct, as the assignment is to match a word that starts with `dog` and ends with `cat`. You can make .* non-greedy by adding ? at the end, but it's not needed in this case, as the engine should backtrack. Something like this should work: /\bdog[\w_-]*cat\b/ (assuming _ and - should be allowed inside words). You can also specify word-separators ([^ ] instead of [\w_-]) if that's easier to read.
[ Parent
| on HN ]
There are no comments on this comment yet.