How to extract email address from string field with a custom function?

How to extract email address from string field with a custom function?

Hi Support,

Current Functionality
I have a flow in Zoho Flow that receives information via a JSON webhook POST and then updates/creates records using this information into Zoho CRM. A specific piece of that information is "comments" which is pushed to a field in Zoho CRM called "comments".

What I Want
An example of the comments string field below:



I want to be able to extract the email address from the comments field and place it into the email field (or any other alternative as long as I can extract the email address) which will lookup and associate any accounts and contacts. How can I do this with a script? Maybe a script that can extract all the text between the commas (,) which have an "@" sign?

N.B. The information in the comments can come in any order.

Let me know what is possible and thanks.