Java Regex to Validate Full Name allow only Spaces and Letters

前端 未结 14 2475
抹茶落季
抹茶落季 2020-11-28 04:50

I want regex to validate for only letters and spaces. Basically this is to validate full name. Ex: Mr Steve Collins or Steve Collins I tried this regex.

14条回答
  •  自闭症患者
    2020-11-28 05:06

    To support language like Hindi which can contain /p{Mark} as well in between language characters. My solution is ^[\p{L}\p{M}]+([\p{L}\p{Pd}\p{Zs}'.]*[\p{L}\p{M}])+$|^[\p{L}\p{M}]+$

    You can find all the test cases for this here https://regex101.com/r/3XPOea/1/tests

提交回复
热议问题