Policy User Logon Name: Compound name

Hello!
In Spain it is very common to have compound names, for example: Maria Del Carmen.
I am looking for how to create the samaccountname as follows:
Maria (Attribute 1)
Del Carmen (Attribute 2)
Perez (Attribute 3)
First letter of attribute 1 + First letter of attribute 2 (without "Del") + attribute 3
The idea is that attribute 2 is counted from space because it can be "From" or "From"
Can you help me?
Thank you!