Changed permalink structure. Need help with redirecting old posts

I just changed the urls structure of my site and want old urls to be forward to the new without the use of redirection plugin.

Old structure: /%category%/%year%/%day%/%postname%/

New: /%postname%/

Can anyone you tell me the regix code for the redirect than I can insert in the .htaccess file? Thanks.

P.S. I tried yoast code regenerator and and it redirected the old urls to the new urls without the end trailing slash and then redirected again with the trailing slash. So, it generated 2 redirect chains instead of one.

I am not able to figure out the .htaccess code needed and the Yoast permalink generator code RedirectMatch 301 ^/([^/]+)/([0-9]{4})/([0-9]{2})/([^/]+)/$ https://www.website.com/$ 4 seems to cause redirect chain issue.

I would like to know how to correct this code RedirectMatch 301 ^/([^/]+)/([0-9]{4})/([0-9]{2})/([^/]+)/$ https://www.website.com/$ 4 so I can insert in my htaccess file. Thanks.