Take a look at the string functions: https://docs.mendix.com/refguide/string-function-calls/
You can use the length() function to determine the length of a string and the substring() function to get the characters from certain positions.
Or check out this post with a more detailed answer:
https://forum.mendix.com/link/space/studio-pro/questions/119385