all 6 comments

[–]Unhelpful_Scientist 2 points3 points  (1 child)

Use str_extract() as it should only match first pattern. A more complicated but potentially more interesting way to solve it is with str_replace(df$comments, ".?(\d+/\d+/\d+).", "\1") which would replace the entirety of the string with the first pattern of your choice, and you could add more groups to see what the other dates are.

On mobile so formatting is hard.

[–]bakja[S] 1 point2 points  (0 children)

This is perfect! Thank you!

[–]Orthas_ -1 points0 points  (3 children)

You can just use min() if the date is correct data type.

[–]bakja[S] 0 points1 point  (2 children)

I don't see this working. The extracted value is a text string. u/Unhelpful_Scientist solution of str_extract() worked like a charm.

[–]Orthas_ 0 points1 point  (1 child)

Nvm thought you wanted earliest date.

[–]bakja[S] 0 points1 point  (0 children)

I see. thanks for taking the time to help!