contacts.splitContactName
Description
Automatically split a single string name into 3 separate fields for title, first name and surname respectively.

Parameters
none

Return value
names array (3 elements consisting of title, first name and surname respectively)

Example

    local names = {};

    names = contacts.splitContactName("Mr Luke Skywalker")
    print("'" .. names.title .. "' '" .. names.firstName .. "' '" .. names.surname .. "'")

    names = contacts.splitContactName("Mr Have Fancy-Surname")
    print("'" .. names.title .. "' '" .. names.firstName .. "' '" .. names.surname .. "'")

    names = contacts.splitContactName("Mr Two First Names")
    print("'" .. names.title .. "' '" .. names.firstName .. "' '" .. names.surname .. "'")

    names = contacts.splitContactName("Dr. Emmett Brown")
    print("'" .. names.title .. "' '" .. names.firstName .. "' '" .. names.surname .. "'")

    names = contacts.splitContactName("Prof Albert Einstein")
    print("'" .. names.title .. "' '" .. names.firstName .. "' '" .. names.surname .. "'")

    names = contacts.splitContactName("Mr and Mrs John Doe")
    print("'" .. names.title .. "' '" .. names.firstName .. "' '" .. names.surname .. "'")

    names = contacts.splitContactName("Mr & Mrs John Doe")
    print("'" .. names.title .. "' '" .. names.firstName .. "' '" .. names.surname .. "'")

    names = contacts.splitContactName("Mr/Mrs John Doe")
    print("'" .. names.title .. "' '" .. names.firstName .. "' '" .. names.surname .. "'")

    names = contacts.splitContactName("Mr / Mrs John Doe")
    print("'" .. names.title .. "' '" .. names.firstName .. "' '" .. names.surname .. "'")

    names = contacts.splitContactName("Mr + Mrs John Doe")
    print("'" .. names.title .. "' '" .. names.firstName .. "' '" .. names.surname .. "'")


Comments

See also

Back
Generated on the 26 June 2024 at 22:01:27 (UK Time)