Find email in text

0
Hi all! I have a fairly simple question, if I have a string and I want to find an email in this string, how can I do this?  For example the text is:   Wow this is amazing, please email me at test@test.nl And I want to know whether there is an email. Using  isMatch($Text,@REGEX_EMAIL)  does not seems to work.   Any ideas?     Found the solution using the Java regex library:   { // BEGIN USER CODE Pattern pattern = Pattern.compile(regularExpression); Matcher matcher = pattern.matcher(inputString); return matcher.matches(); // END USER CODE }
asked
1 answers
1

First use the find function to find the @ character. So create a variable integer beforeAtInt and fill it with find($mystring, ‘@’). This will return a value of the location of that character. Then use substring to only get the string part before the @ by using the substring function. So create variable beforeAt and fill it with substring($mystring, $beforeAt) to give you that part. Now find the last space in that string by using findLast. So findlast($beforeAt, ‘ ‘). That gives you the character location of the space before the start of your mail address. Now do the same to find out if there is a space after the @ character. If none is found (result -1) it means that there is no text after it. I would double check if the last character is a dot (.) that could be there because it could mean the end of the sentence. You now have all the components to put all the parts together.

Regards,

Ronald

 

answered