HI, 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?
hi 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
If I can repharse your requirement, it will be " To check whether the user input contains anything else other than a to z or A to Z characters"
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
You can't wake a person who is <b><i>pretending</i></b> to be asleep.<br />Like what <b>"it"</b> does not like - <i> Gurdjieff </i>
Originally posted by Santhana Lakshmi.S: hi 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.