• Login
Community
  • Login

Amazon review date regular expression doesn't work e.g. December 23, 2021 /([A-Z][a-z]+) \d{1,2}, \d{4}/

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
search patternsearchsearch & replacesearch-string
7 Posts 6 Posters 408 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J
    Jeff Kang
    last edited by Jeff Kang Apr 2, 2023, 7:57 PM Apr 2, 2023, 7:57 PM

    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

    J T 2 Replies Last reply Apr 2, 2023, 7:57 PM Reply Quote 0
    • J
      Jeff Kang @Jeff Kang
      last edited by Apr 2, 2023, 7:57 PM

      @Jeff-Kang

      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.

      1 Reply Last reply Reply Quote 0
      • T
        Terry R @Jeff Kang
        last edited by Terry R Apr 2, 2023, 8:31 PM Apr 2, 2023, 8:28 PM

        @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

        1 Reply Last reply Reply Quote 4
        • G
          guy038
          last edited by guy038 Apr 2, 2023, 10:03 PM Apr 2, 2023, 9:49 PM

          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

          1 Reply Last reply Reply Quote 1
          • M
            Mark Olson
            last edited by Apr 2, 2023, 10:27 PM

            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.

            L C 2 Replies Last reply Apr 3, 2023, 9:05 PM Reply Quote 2
            • L
              Lycan Thrope @Mark Olson
              last edited by Apr 3, 2023, 9:05 PM

              @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. :)

              1 Reply Last reply Reply Quote 1
              • C
                Coises @Mark Olson
                last edited by Coises Apr 4, 2023, 12:56 AM Apr 4, 2023, 12:55 AM

                @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…

                1 Reply Last reply Reply Quote 3
                4 out of 7
                • First post
                  4/7
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors