Jump to content

GetLastName ( FullName )


This topic is 5661 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Name & Parameters: [color:red][big] GetLastName ( FullName ) [/big]

Description: Returns a person's Last Name. Ignores suffixes such as 'Jr', 'Sr', 'III'. Also returns a hyphenated Last Name

Sample Input:

1) Prof. Henry James

2) John Smith-Peters

3) Henry Higgins PhD

Results:

1) James

2) Smith-Peters

3) Higgins

Recursive: no

Formula:

/* CF: Returns A Contact's Last Name from a Full Name

    CF:  GetLastName

            FullName

*/



Let ( [

         name= Substitute ( FullName; "-" ; "00" ); // Needed because FM treats lots of characters as separators

         nword= WordCount( name ); 

         rw= RightWords ( name ; 1 );

         suffix =  Case( rw= "SR" or rw= "JR" or rw= "II" or rw= "III" or rw= "IV" or rw= "MD" or rw= "DR" or rw= "PhD" or rw= "Esq"; rw;"") // Trap suffix if it exists

        ];



Substitute( Case( WordCount( suffix) > 0; MiddleWords ( name ; nword -1; 1 ); MiddleWords( name; nword; 1 ) ); "00"; "-") // Replace with dash



) 

Required Functions:

Author(s): Steveinvegas

Date: 06/03/06

Credits:

Disclaimer:

FM Forums does not endorse or warrantee these files are fit for any particular purpose. Do not post or distribute files without written approval from the copyright owner. All files are deemed public domain unless otherwise indictated. Please backup every file that you intend to modify.

Link to comment
Share on other sites

This topic is 5661 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.