# lname

### lname(source)

Extract the last name from a name string, using the name suffix table to strip off the suffixes.

### lname(source, default)

Extract the last name from a name string, using the name prefix table to strip off prefixes. If a last name is not found, return the default supplied.

## Arguments

Argument | Data Type | Description
source | string | String to search
default | string | name to return of no last name found

## Returns

The last name from a name string.

## Description

lname() is used to find the last name of a contact in a string. It can correctly return the last name from names such as:
John Smith
Mr John Smith
Dr. John Smith
Dr Smith
Dr John Smith III

It does this by using the name prefix and suffix maps in 'Tools - Options - Name Prefixes and Suffixes' to strip off the prefixes (Mr, Miss, Mrs, Dr, ...) and the suffixes (PhD, III, 2nd, ...) to leave a first name / last name pair. It then returns the last word from the pair. If there is only one word left, it assumes that this is the last word.

is supplied with a set of prefixes and suffixes to strip, but you can alter them to add more, modify the existing ones, or remove them.

The maps allow the use of regular expressions.

## Examples

Assume that:

1. field 1 has the string "Mr John Smith III"

2. field 2 has "Smith"

3. field 3 has "Mr Smith"

Example | Returns | Description
lname(#1) | "Smith" |
lname(#2) | "Smith" |
lname(#3) | "Sir or Madam" |

## See Also

fname(), findWord()