Question

I am trying to extract just the email address from a string of text, for example: Joe Blogs | Senior Advisor | Joe.bloggs@example.co.uk | pointOfContact

  • 20 September 2021
  • 5 replies
  • 9 views

I have tried the StringReplacer but I'm struggling to remove everything I need to, without also removing part or all of the email as well. Any help would be appreciated, thank you.


5 replies

Badge +16

Hi @clare42​ ,

 

Try this regex with the StringSearcher transformer.

[\w.+]+@[\w+\.\w.]+

The output should be: Joe.bloggs@example.co.uk

Hi @clare42​ ,

 

Try this regex with the StringSearcher transformer.

[\w.+]+@[\w+\.\w.]+

The output should be: Joe.bloggs@example.co.uk

Hi, thank you. It works much better, but it seems to cut the end bit off, so I end up with Joe.Bloggs@example

Userlevel 4
Badge +30

Hi @clare42​ ,

 

Try this regex with the StringSearcher transformer.

[\w.+]+@[\w+\.\w.]+

The output should be: Joe.bloggs@example.co.uk

Nice!

Badge +16

Hi, thank you. It works much better, but it seems to cut the end bit off, so I end up with Joe.Bloggs@example

Hi @clare42​ . My regular expression knowledge isn't the best, so you might want to use this regular expression that should be a safer bet in capturing email addresses. 

 

Source: https://emailregex.com/

Regex: 

(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])

 

In my testing it does in fact capture the email address you provided in your example. 

parametersfme

Hi, thank you. It works much better, but it seems to cut the end bit off, so I end up with Joe.Bloggs@example

Thank you 😊

Reply