This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes regular expression for alphanumeric Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "regular expression for alphanumeric" Watch "regular expression for alphanumeric" New topic
Author

regular expression for alphanumeric

kalyen kumar
Ranch Hand

Joined: Sep 18, 2008
Posts: 53
hey everybody,

I am trying to write a regular expression which accepts only alphanumeric

but the rule is ......it should not accept only alphabet or only numeric words

Examples:

word123--------> TRUE
123word--------->TRUE
word------------->FALSE (because only alphabet)
1234------------->FALSE (because only numeric)

Can any one help me in writing this.......

Thanks in advance

Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18103
    
  39

Well, it's pretty straightforward -- what have your tried so far?

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
kalyen kumar
Ranch Hand

Joined: Sep 18, 2008
Posts: 53
i just found that this is working......



am I correct....?
still any easy way to do this...

Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18103
    
  39


am I correct....?


yes...

still any easy way to do this...


Well. That depends.... Did you read up on regexes and figured out the solution yourself? Or did you simply got the solution from someone else? We can't really give you a hint on an "easier way" (assuming that there is one), if you don't understand this regex.

Henry


kalyen kumar
Ranch Hand

Joined: Sep 18, 2008
Posts: 53
Hey thanks for your support,

Actually, I needed this regex somewhere in between my project.
As I had little time and as I am not an expert of regex, so tried to understand some basics of it.
I searched for the answer but could find only a close answer, so i modified it to suit my requirement.

My knowledge in regex is, I can only understand them but writing them on my own needs some more learning....

Once again thanks for your encouragement.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: regular expression for alphanumeric
 
Similar Threads
Regular Expression in Javascript
Validation Using Regular Expression in Javascript
Need help assign java string to java script variable
How to combine JSP <c:if> with JSF <f:validateLength>
Old COBOL dude needs direction