We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,642 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Java Regular Expressions

Hallo everybody,

Can someone help me with some regexs for testing :
- in a textbox , i need to test only string carachters , not numbers,digits, spaces;
- in a textbox , i want to text only numbers, not strings, char..other.

Please..

Pattern patternForInfo = Pattern.compile("[a-zA-Z]", Pattern.CASE_INSENSITIVE);
Pattern patternForNumere = Pattern.compile("^[A-Z]{3,}", Pattern.CASE_INSENSITIVE);

2
Contributors
2
Replies
1 Hour
Discussion Span
2 Years Ago
Last Updated
3
Views
mihu
Newbie Poster
3 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

instead of checking if it is a letter or a special character. you could check if it is a number between 0 to 9 so if all the characters are numbers you have number. it will be a lot easier for you.
even though you have a nice way to get the job done I suggest you use some of prewriten classes from. java api. for example. Character class has nice features that you can use. for example you can use isDigit() function to get if the character is a digit or not. anything you wanna do with a character you can do it with this class.

<snip>

Nisha105
Newbie Poster
1 post since Oct 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

instead of checking if it is a letter or a special character. you could check if it is a number between 0 to 9 so if all the characters are numbers you have number. it will be a lot easier for you.
even though you have a nice way to get the job done I suggest you use some of prewriten classes from. java api. for example. Character class has nice features that you can use. for example you can use isDigit() function to get if the character is a digit or not. anything you wanna do with a character you can do it with this class.

rapidshare downloads

the first ideea is very good and useful for me,
thank you very much :)

mihu
Newbie Poster
3 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0561 seconds using 2.65MB