Regex - Return First and Last Name

前端 未结 7 1111
一整个雨季
一整个雨季 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:23

    If you're defining first and last name as the text before the first space and after the last space, then just split the string on spaces and grab the first and last elements of the array.

    However, depending on the context/scope of what you're doing, you may need to re-evaluate things - not all names around the world will meet this pattern.

    0 讨论(0)
提交回复
热议问题