Given a set of full names (multiple first names and last name/surname combined), these regular expressions can be used to split up the string into first names and a single last name/surname. This takes into account some common Afrikaans surnames with muliple parts (e.g. van der Merwe
). These regular expressions are not perfect and cannot cover all cases. Adapt it for your needs. Use the capture groups to retrieve the first names and surname.
([\w-]+(?: +(?!(?:Le +\w+)|(?:D[eou] +\w+)|(?:(?:Janse(?:n) +)?V[ao]n +(?:Der +)?\w+))[\w-]+)*) +((?:[\w-]+ )*[\w-]+)
Input | Output first name(s) | Output surname |
---|---|---|
Sibusiso Madikizela | Sibusiso | Madikizela |