jokerino
jokerino

Reputation: 13

Google Sheets REGEXTRACT the second date of a string

So I have the following string example in a Google Spreadsheet:

AN_U_John_Doe_01.01.1900_24.01.2022.pdf

I want to REGEXTRACT the second date, which would be:

24.01.2022

I did the following, which works but I'm sure there's a better way to do this:

REGEXEXTRACT($A1;"(\d+\.\d+\.\d+\.)") which results in: 24.01.2022. (notice the dot at the end)

and then I do REGEXEXTRACT($B1;"(\d+\.\d+\.\d+)") which gets rid of the dot.

Is there a way to do this in one regextract? Also the front part of the string might not always be the same, can be shorter or longer only the dates are always in the end like that.

Upvotes: 1

Views: 250

Answers (2)

Jason E.
Jason E.

Reputation: 1221

You can join your two REGEXEXTRACTs by using this:

=REGEXEXTRACT($A1,"(\d+\.\d+\.\d+)\.")

Upvotes: 2

player0
player0

Reputation: 1

try:

=REGEXEXTRACT(A1; "_(\d+.\d+.\d+).pdf$")

Upvotes: -1

Related Questions