PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → Position fromEnd return position from start. Get domain name from email adres
Position fromEnd return position from start. Get domain name from email adres
Iniciado por walter, 06,feb. 2018 08:18 - 3 respuestas
Publicado el 06,febrero 2018 - 08:18
Hi all,
I'm new to WD22 (coming from Clarion)
I want to extract the domain name from the email address . I need to find the @ in the string and then extract the string from that position (@) to the end

gwasEmailAddress is string

gwasEmailaddress = "walter@thisdomain.nu"
gwi2Position@ = Position(gwasEmailAddress , "@", 0, FromEnd)
However
Position returns 7 so counted from the start of the string?!

What's wrong with my code? Does anyone has an example how to extract @thisdomain.nu from the string?

Best regards
Walter - Sabra - The Netherlands
Publicado el 06,febrero 2018 - 15:38
Hi Walter,

> gwasEmailAddress is ansi string
gwasDomain is ansi string

gwasEmailaddress     = "walter@thisdomain.nu"

gwasDomain = extractstring(gwasEmailAddress,2,"@")

that's all...

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Ready for you: WXShowroom.com, WXReplication (open source) and now WXEDM
(open source)

More information on http://www.fabriceharari.com



gwi2Position@          = Position(gwasEmailAddress , "@", 0, FromEnd)
However
Position returns 7 so counted from the start of the string?!

What's wrong with my code? Does anyone has an example how to extract
@thisdomain.nu  from the string?

Best regards
Walter - Sabra - The Netherlands
Publicado el 06,febrero 2018 - 16:17
Yes! off course : the @ is the separator in the string.

But I still wonder why Position(String, "@", 0 , FromEnd) starts counting from the begin . On the other hand, the docs say start searching from the end . It does not state that the position is counted from the end also.

Thanks
Walter
Publicado el 06,febrero 2018 - 18:54
and now you are answering your own question, and with the correct answer
at that...

a position is ALWAYS from the beginning of the string...

Le 2/6/2018 à 10:17 AM, Walter van der Horst a écrit :
Yes! off course : the @ is the separator in the string.

But I still wonder why Position(String, "@", 0 , FromEnd) starts
counting from the begin . On the other hand, the docs say start
searching from the end . It does not state that the position is counted
from the end also.

Thanks Walter