Regex - Return First and Last Name

前端 未结 7 1118
一整个雨季
一整个雨季 2021-01-15 08:51

I\'m looking for the best reliable way to return the first and last name of a person given the full name, so far the best I could think of is the following

7条回答
  •  失恋的感觉
    2021-01-15 09:17

    I think your best option is to simply treat everything after the first name as the surname i.e.

    William Henry Gates
    Forename: William
    Surname: Henry Gates

    Its the safest mechanism as not everyone will enter their middle name anyway. You can't simply extract William - ignore Henry - and extract Gates as for all you know, Henry is part of the Surname.

提交回复
热议问题