regexgoogle-sheets

How to extract the whole match and not just the captured group?


This formula will result in "am" or "pm".

=REGEXEXTRACT(a1,"\d+:\d\d (am|pm)")

How do I make it show everything and not just the captured group? I want it to behave like normal regex, which would show the whole match.


Solution

  • You can change the capture group into a non-capturing group:

    =REGEXEXTRACT(a1,"\d+:\d\d (?:am|pm)")