How to pull out text from a field that has constant value
This can be used to gather specific information from within fields, in this example we will go through pulling out the domains of emails. This is done through finding the placement of the ‘@’ and then pulling out the information after this.
So our constant value is ‘@’. To begin, we need three fields
- Email (Email)
- Position At Email Address (Number)
- Email Domain (Text)
Field 1 is our email field.
Field 2 - will be a number field. In this case, it is labelled ‘Position Of Constant’.
This is used to find the constant, ‘@’ from within the email fields. The expression is:
If(Substring([Email], 2, 1)=’@’, 2,0)+ which goes into the expression section of this field.
This is an if expression where you are pulling out information from the email field, it checks to see where in the email the @ is through checking each character to see if it is an @.
The number after [Email] refers to each character that it is checking, the 1 shows that you are just checking this one character.
The = is checking if the character is in fact an ‘@’, then it selects ‘2’ which was the position of the @ but if not, nothing happens ‘0’.
This means that there will be multiple if expressions back-to-back, checking each character.
This looks like this:
if(Substring([Email],2, 1)='@', 2,0)+
if(Substring([Email],3, 1)='@', 3,0)+
if(Substring([Email],4, 1)='@', 4,0)+
if(Substring([Email],5, 1)='@', 5,0)+
if(Substring([Email],6, 1)='@', 6,0)+
if(Substring([Email],7, 1)='@', 7,0)+
if(Substring([Email],8, 1)='@', 8,0)+
if(Substring([Email],9, 1)='@', 9,0)+
if(Substring([Email],10, 1)='@',10,0) +
if(Substring([Email],11, 1)='@',11,0) +
if(Substring([Email],12, 1)='@', 12,0)+
if(Substring([Email],13, 1)='@', 13,0)+
if(Substring([Email],14, 1)='@', 14,0)+
if(Substring([Email],15, 1)='@', 15,0)+
if(Substring([Email],16, 1)='@', 16,0)+
if(Substring([Email],17, 1)='@', 17,0)+
if(Substring([Email],18, 1)='@', 18,0)+
if(Substring([Email],19, 1)='@', 19,0)+
if(Substring([Email],20, 1)='@',20,0) +
if(Substring([Email],21, 1)='@',21,0) +
if(Substring([Email],22, 1)='@', 22,0)+
if(Substring([Email],23, 1)='@', 23,0)+
if(Substring([Email],24, 1)='@', 24,0)+
if(Substring([Email],25, 1)='@', 25,0)+
if(Substring([Email],26, 1)='@', 26,0)+
if(Substring([Email],27, 1)='@', 27,0)+
if(Substring([Email],28, 1)='@', 28,0)+
if(Substring([Email],29, 1)='@', 29,0)+
if(Substring([Email],30, 1)='@',30,0) +
if(Substring([Email],31, 1)='@',31,0) +
if(Substring([Email],32, 1)='@', 32,0)+
if(Substring([Email],33, 1)='@', 33,0)+
if(Substring([Email],34, 1)='@', 34,0)+
if(Substring([Email],35, 1)='@', 35,0)+
if(Substring([Email],36, 1)='@', 36,0)+
if(Substring([Email],37, 1)='@', 37,0)+
if(Substring([Email],38, 1)='@', 38,0)+
if(Substring([Email],39, 1)='@', 39,0)+
if(Substring([Email],40, 1)='@',40,0) +
if(Substring([Email],41, 1)='@',41,0) +
if(Substring([Email],42, 1)='@', 42,0)+
if(Substring([Email],43, 1)='@', 43,0)+
if(Substring([Email],44, 1)='@', 44,0)+
if(Substring([Email],45, 1)='@', 45,0)+
if(Substring([Email],46, 1)='@', 46,0)+
if(Substring([Email],47, 1)='@', 47,0)+
if(Substring([Email],48, 1)='@', 48,0)+
if(Substring([Email],49, 1)='@', 49,0)+
if(Substring([Email],50, 1)='@',50,0)
Which should look like this:
Field 3 is a text field.
This is where the final expression will be, which selects the section of the email after the ‘@’.
This is the expression:
Expression: SubString([Email], [PositionofConstant] + 1, Len([Email]) - [PositionofConstant] -1)
It picks out the email and then finds the position of constant [PositionOfConstant], which was field two. Then it takes the following character through the ‘+1’.
The total length of the email field is shown through Len([Email]) minus the position of constant. This will select the rest of the email and pull it into the text field
It should look like this:
Please sign in to leave a comment.
Comments
0 comments