# fname

### fname(source)

Extract the first name from a name string, using the name prefix table to strip off prefixes.

### fname(source, default)

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

## Arguments

Argument | Data Type | Description
source | string | String to search
default | string | String to return if no first name is found

## Returns

The first name from a name string.

## Description

fname() is used to find the first name of a contact in a string. It can correctly return the first 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 first word from the pair. If there is only one word left, it assumes that this is the last word, and returns either an empty string, or the default if one is supplied.

Inaport 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
fname(#1) | "John" |
finame(#2) | "" |
fname(#3, "Sir or Madam") | "Sir or Madam" |

## See Also

lname(), findWord()