-4

This is my string

word = " Saturday Fortune 08-09-2022 (4872) Draw Numbers "

But I only want to print the date in the string like this

'08-09-2022'

So how can I achieve this?

  • 1
    Does this answer your question? [Extracting date from a string in Python](https://stackoverflow.com/questions/3276180/extracting-date-from-a-string-in-python) – Warkaz Sep 10 '22 at 13:10

1 Answers1

1

Should use a regular expression to find that part in the string. Something like:

import re
match = re.search(r'\d{2}-\d{2}-\d{4}', word)

This already seems to be answered as a subproblem in this thread.

Warkaz
  • 845
  • 6
  • 18