Regular Expression to find “lastname, firstname middlename” format

后端 未结 5 1736
挽巷
挽巷 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:50

    ^([a-zA-Z]+)\s*,\s*([a-zA-Z]+)\s+([a-zA-Z]+)$
    

    I think you are looking for this.just grab the groups to get your needs.See demo.

    http://regex101.com/r/hQ1rP0/6

提交回复
热议问题