PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → Extract initials and surname from field.
Extract initials and surname from field.
Iniciado por guest, 04,nov. 2017 20:22 - 5 respuestas
Publicado el 04,noviembre 2017 - 20:22
Hi folks,

I'm struggling with the following. String: "A.B. Smith" needs to result in string "A.B." and string "Smith". I other words I want to extract initials and name from a string into 2 separate strings.

Can somebody put me on the right track.

Best regards,

Aad
Publicado el 04,noviembre 2017 - 20:41
Hi Aad,

Maybe something like this:

StringArray is array of strings

StringToArray("A.B. Smith",StringArray, " ")
FOR i=1 _TO_ StringArray..Occurrence
Info(StringArray)
END

Regards,
Bart
Publicado el 05,noviembre 2017 - 01:08
Hi Bart,

Thank you for your example. I played around with it and looked into the help file. Can you shed a little more light on what you mean, because I cannot see how this can make 2 strings from one string.

Best regards,

Aad
Publicado el 05,noviembre 2017 - 09:43
Hi Aad,




Regards,
Bart
Publicado el 05,noviembre 2017 - 11:42
Hi if the space is the separator use the function below

ExtractString(InitialString,1," ") gives "A.B."
ExtractString(InitialString,2," ") gives "Smith"
Publicado el 05,noviembre 2017 - 14:01
Perfect. Thank you very much.

Regards,

Aad