In my project i want to check whether the user's input string contains numbers,commma,colon,double and single quotes and also any special characters
Iam getting the user input as a string.
Can anyone tell me how to check for this?
Thanks a lot.
Here anything else are numbers,colon,double,special characters etc
So you create a pattern to get all the matches that does not contain a-z or A-Z. After you compile the pattern, the matches should return only those values that do not contain a-z / A-Z which will be special chars, numbers, colons etc.
So I suggested the pattern would be [^a-zA-Z]
^ symbol is not negation.
For concrete examples refer tutorial link / API reference
Originally posted by Santhana Lakshmi.S:
If i java.util.regex class i need to give the pattern where the special characters will occur.Am i right?
But in my case, the input string is user defined one.
In that,at any place the special characters and numbers will occur.
How to check those?
Thanks in advance
Regular expression syntax allows you to specify the characters without worrying about their exact placement in the string. For instance the pattern [a-z]* matches zero or more lower case letters. It doesn't matter what order the letters are in.