Amazon review date regular expression doesn't work e.g. December 23, 2021 /([A-Z][a-z]+) \d{1,2}, \d{4}/
-
Hi there, I’m trying to clean up a big list of Amazon reviews for easier reading. I just want over see the review content, and not the dates. I’ve never used a regular expression before, so I asked Bing to create one for the following date format
December 23, 2021
/([A-Z][a-z]+) \d{1,2}, \d{4}/
Is there a reason why this won’t match in Notepad++, even with the regular expression search mode checked on? Does Notepad have a different regex format?
Best,
Jeff -
I changed the prompt to
I need a Notepad++ regular expression that removes all dates in this format December 23, 2021
That instead gave me:
\b(?:January|February|March|April|May|June|July|August|September|October|November|December)\s+\d{1,2},\s+\d{4}\b
This worked, thanks.
-
@Jeff-Kang said in Amazon review date regular expression doesn’t work e.g. December 23, 2021 /([A-Z][a-z]+) \d{1,2}, \d{4}/:
Is there a reason why this won’t match in Notepad++, even with the regular expression search mode checked on? Does Notepad have a different regex format?
I’m not sure if I’m miffed that an AI engine can now create regular expressions or just plain amused.
In regards your first solution from Bing, it used the
/
which is a delimiter for the JavaScript version of regular expressions. Notepad++ was using it as a character to find. There are many flavours of regular expressions which all have their own way of creating code, all very similar, but often you will find code in one just won’t work in another without some alterations taking place.If you removed both of those
/
from the first solution that will work. Your second solution also works but is not concise, that’s the beauty of regular expressions, many ways to achieve the same result. None are wrong, but some can be complicated to read.You can read about what Notepad++ uses by looking in the FAQ section. There are many posts with interesting information.
Terry
-
Hello, @jeff-kang, @terry-r and All,
@jeff-kang, if really, the Bing
ChatGPT
gave you the answer :\b(?:January|February|March|April|May|June|July|August|September|October|November|December)\s+\d{1,2},\s+\d{4}\b
to the question :
I need a Notepad++ regular expression that removes all dates in this format December 23, 2021
I personally think that it’s the exact regex to use in such case ! The power of AI is truly impressive !
And the re-formulation of your question was rather pertinent and gave an answer adapted to our software !
So, for example, I’m still confortable with my recursive regex answer to @mark-olson question here, but until when ?!!!
Best Regards,
guy038
-
Eh, I wouldn’t worry too much about the fact that ChatGPT can generate a regex that matches that specification, since
generate a regex that matches a date in such-and-such a format
has probably appeared a lot of times in its training data. -
@Mark-Olson ,
Agreed. The problem with depending on tools (ChatGPT) to do your work for you, is the same as using a calculator in a math class. Unless you know how to do the task without the tool, you’ll never know if the tool is working right. The tool should just be used to speed up what you already know how to do.
For example, knowing how to add, means you’ll know if the calculator made a mistake or a wrong button was hit that made the calculator give a wrong answer. You actually need to be able to fact-check your tools. They aren’t there to replace your brain. :) -
@Mark-Olson said in Amazon review date regular expression doesn’t work e.g. December 23, 2021 /([A-Z][a-z]+) \d{1,2}, \d{4}/:
Eh, I wouldn’t worry too much about the fact that ChatGPT can generate a regex that matches that specification, since
generate a regex that matches a date in such-and-such a format
has probably appeared a lot of times in its training data.A very dear friend of mine would frequently shout in frustration, “Why don’t you just answer the question?!” after doing a Google search. Despite being very intelligent and reasonably computer-savvy, she could not seem to escape the illusion that the search was responding to what she asked and not just matching words. So I suppose we shouldn’t be surprised that people using ChatGPT can’t keep in mind that it literally does not know what it is talking about. At best, it’s as accurate as the average source in its training data, which… should give us all pause…