Based off of the info from the comments mentioning this has to be done in email in 'real time', the easiest way I can think of to test this via AMPscript is to do the following:
- Set the string into an AMPscript variable
- Build a rowset from that string using space as the delimiter
- Iterate through the rowset and count the length of each row
- If you find a row with a count of 1 - set an ampscript var as a flag
- Use that flag for deciding which salutation to use.
For example:
%%[
SET @flag = 0
SET @fName = AttributeValue("FirstName")
SET @fName_RS = BuildRowsetFromString(@fName," ")
FOR @i=1 TO RowCount(@fName_RS) DO
SET @fName_R = Row(@fName_RS,@i)
SET @temp = Field(@fName_R,1)
SET @length = Length(@temp)
IF @length == 1 THEN
SET @flag = 1
ENDIF
NEXT @i
IF @flag == 1 THEN
SET @salutation = "One letter variant"
ELSE
SET @salutation = "Other version"
ENDIF
]%%