Extract text right of @ character

  • 18 August 2021
  • 1 reply
  • 9 views

Hi,

 

In Nintex forms i have a control which is connected to a person or group field. For a given email address, e.g. "john.smith@hello.co.uk" how could I extract the text after the "@" Which, in this case would be "@hello.co.uk". should i use calculated value control?

 

Any ideas?

 

Thanks


1 reply

Userlevel 5
Badge +14

it kinda depends on how you'd like to use the value you're extracting! If you need to have it displayed on the Form, then certainly a Calculated Control would do the trick. But if you just wanted to use it in code, then why not just extract it in real-time?


 


No matter using a variation of: 


"john.smith@hello.co.uk".match(/@(.*)/)[1];


Should produce the result you'd like.

Below are two examples of how one might approach it either way:


/* Directly in a Calc Control formula */

{email_Control_Reference}.match(/@(.*)/)[1];


 


Used in code by passing the Email Control into a function as an argument:


(function(emailControl){
var emailHost = emailControl.match(/@(.*)/)[1];
/* Your Other Code */
}({email_Control_Reference}))

 


Let me know if you need further help!

Reply