Regular Expression to find “lastname, firstname middlename” format

后端 未结 5 1734
挽巷
挽巷 2021-01-18 05:22

I am trying to find the format \"abc, def g\" which is a name format \"lastname, firstname middlename\". I think the best suited method is regex but I do not have any idea i

5条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-18 05:54

    I think this one will also work and a bit shorter than yours:

    ([A-Z][a-z]*)(?:,\s*)?
    

    Demo

    Or you can use split using this regex:

    (,?\s+)
    

提交回复
热议问题