Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

detect the next 2 characters

Former Member
0 Kudos
117

Dear All,

how can I detect the next 2 characters after @ at a email address.

regards

marco m

1 ACCEPTED SOLUTION

Former Member
0 Kudos
81

HI,

Check the following code.


split v_email at '@' int0 var1 var2.
var3 = var2+0(2).

.

Suppose v_email contains an email address. Then var1 will contain the first part (brfore @) and var2 will hold the second part (after @).

Var3 will have first two characters.

Hope this helps.

Regards,

Sachin

7 REPLIES 7

former_member555112
Active Contributor
0 Kudos
81

Hi,

use SPLIT statement to split the address into 2 variable or an internal table splitting at '@'.

And then use offset to find the 2 characters.

Regards,

Ankur Parab

Edited by: Ankur Parab on Aug 4, 2009 7:57 PM

0 Kudos
81

is that the only way ?

0 Kudos
81

Hi,

You can also use CP to find the postion of '@" in an email address.

The position will be in SY-FDPOS field if the CP is successful and then make use of offset to find the next 2 characters.

Regards,

Ankur Parab

0 Kudos
81

yes, you can search for @ and use the position to get the next two chars or you can use regular expressions.

0 Kudos
81

Hi,

You could use the SEARCH command, which will put the position of the @ into field sy-fdpos. Then you can use this value as the offset to get the next two characters.

But I prefer the suggestion to use SPLIT.

Regards,

Nick

Former Member
0 Kudos
82

HI,

Check the following code.


split v_email at '@' int0 var1 var2.
var3 = var2+0(2).

.

Suppose v_email contains an email address. Then var1 will contain the first part (brfore @) and var2 will hold the second part (after @).

Var3 will have first two characters.

Hope this helps.

Regards,

Sachin

0 Kudos
81

REPORT  ZREGEX.

data:
  s type string,
  substr type string.

START-OF-SELECTION.

// this is needed because its not allowed to post email addresses.
  concatenate `someone` `@` `example.org`into s.

  find FIRST OCCURRENCE OF regex '@(..)' in s submatches substr.

  write:/ s.
  write:/ substr.