Skip to main content
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

  • September 20, 2021
  • 5 replies
  • 42 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

warrendev
Enthusiast
Forum|alt.badge.img+24
  • Enthusiast
  • September 20, 2021

Hi @clare42​ ,

 

Try this regex with the StringSearcher transformer.

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

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


  • Author
  • September 21, 2021
warrendev wrote:

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


danilo_fme
Evangelist
Forum|alt.badge.img+45
  • Evangelist
  • September 21, 2021
warrendev wrote:

Hi @clare42​ ,

 

Try this regex with the StringSearcher transformer.

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

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

Nice!


warrendev
Enthusiast
Forum|alt.badge.img+24
  • Enthusiast
  • September 21, 2021
clare42 wrote:

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


  • Author
  • September 23, 2021
clare42 wrote:

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 😊


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings