简体   繁体   English

没有数字Java Regex Pattern

[英]No digits Java Regex Pattern

I want a regex pattern to check that the string doesn't contain any digits . 我想要一个正则表达式模式来检查字符串是否包含任何数字。

For Illustration : I'm coding a Hospital System and I want from user to enter the name of the patient , Of course the name shouldn't contain any digits , how can I do this by Regex ? 对于插图:我正在对医院系统进行编码,我希望用户输入患者的姓名,当然该名称不应包含任何数字,我该如何通过Regex执行此操作?

\\D is a non-digit, and so then \\D* is any number of non-digits in a row. \\D是非数字,因此\\D*是一行中任意数量的非数字。 So your whole string should match \\D* . 所以你的整个字符串应匹配\\D*

\\A\\D*\\Z \\ A \\ d * \\ž

a good regex cheatsheet here 一个很好的正则表达式cheatsheet在这里

Try: \\D 尝试:\\ D.

See the JavaDoc for Pattern 请参阅JavaDoc for Pattern

Well names usually alphabetical, so this will be good : [ab,AZ, ,-]+ 好的名字通常是按字母顺序排列的,所以这样会很好: [ab,AZ, ,-]+

EDIT : [a-zA-Z- ',]+ 编辑: [a-zA-Z- ',]+

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM