I would like to get everything that appears before the @ symbol in a list of emails and was wondering the best way to do this. Thought we could get the position of the @ symbol then do a substring on the field up to that position. Has anyone done this?
for example want to return johndoe from the email johndoe@hp.comThis message has been edited. Last edited by: Trudy,
WF8 Windows
October 16, 2017, 10:57 AM
Frans
There is a special function for that, use GETTOK and use @ as a delimiter.
DEFINE FILE CAR CNTRY/A10 = LOCASE(10, STRIP(10, COUNTRY, ' ', 'A10'), CNTRY); EMAIL/A30 = CNTRY || '@whatever.com'; TOKEN/A10 = GETTOK(EMAIL, 30, 1, '@', 10, TOKEN); END -* TABLE FILE CAR PRINT CNTRY EMAIL TOKEN BY COUNTRY END
WebFocus 8.201M, Windows, App Studio
October 16, 2017, 04:29 PM
Waz
FYI
As you seem to be on WF8, there is a new function called TOKEN, much simpler than GETTOK.
VAR = TOKEN(string,delimiter,token number)
Waz...
Prod:
WebFOCUS 7.6.10/8.1.04
Upgrade:
WebFOCUS 8.2.07
OS:
Linux
Outputs:
HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!
October 16, 2017, 05:28 PM
jfr99
Thanks Waz ...
DEFINE FILE CAR CNTRY/A10 = LOCASE(10, STRIP(10, COUNTRY, ' ', 'A10'), CNTRY); EMAIL/A30 = CNTRY || '@whatever.com'; TOKEN/A10 = GETTOK(EMAIL, 30, 1, '@', 10, TOKEN); VAR01/A10 = TOKEN(EMAIL,'@',1); END -* TABLE FILE CAR PRINT CNTRY EMAIL TOKEN VAR01 BY COUNTRY END
WebFocus 8.201M, Windows, App Studio
October 17, 2017, 07:31 AM
Trudy
Thanks all, the GETTOK worked but I think I will try the TOKEN as well.
WF8 Windows
October 18, 2017, 01:57 PM
Clif
There's an even easier way in 8.2, a new function SPLIT where you can specify the part of the email address you want to extract: EMAIL_USERID or EMAIL_DOMAIN.