简体   繁体   中英

Print String only if it contains Letters, or Numbers, a space or comma

EDIT,

Would anyone know the code, that will print a String only if it contains, letters or numbers, or a space, or comma.

Many thanks in advance!

You should try this regular expression:

String example = "abC*D005";

if (example.matches("^[a-zA-Z0-9]+$"))
{
    System.out.println(example);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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