There's no need to use a script for this. The regexextract
function can extract the date, which can then be recombined into whatever format. It's best to use three helper columns, which may be hidden (say, X, Y, Z). In X2, put
=regexextract(B2, "(\d{2})/(\d{2})/(\d{4})")
This will place the month, date, and year in cells X2, Y2, Z2. Then in D2, put
=Y2 & "." & X2 & "." & Z2
and you are done.
This also works in arrayformula
mode, handling the entire column at once:
=iferror(arrayformula(regexextract(B2:B, "(\d{2})/(\d{2})/(\d{4})")))
where iferror
suppresses error from cells that don't contain a date.
After that,
=arrayformula(if(len(Z2:Z), Y2:Y & "." & X2:X & "." & Z2:Z, ))
recombines the date, again leaving blanks where no date was parsed out.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments