aspose file tools*
The moose likes Java in General and the fly likes validate the string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "validate the string" Watch "validate the string" New topic
Author

validate the string

Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1268

Hi I need to validate my string with the following critria ....

[A-Z]{6,6}[A-Z2-9][A-NP-Z0-9]([A-Z0-9]{3,3}){0,1}


how could I do it..?


No Kaustubh No Fun, Know Kaustubh Know Fun..
Raymond Tong
Ranch Hand

Joined: Aug 15, 2010
Posts: 230
    
    2

Kaustubh G Sharma wrote:Hi I need to validate my string with the following critria ....

[A-Z]{6,6}[A-Z2-9][A-NP-Z0-9]([A-Z0-9]{3,3}){0,1}


how could I do it..?

Regular Expression in Java
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19556
    
  16

Note that you can replace the {0,1} with ?. Both mean zero or one times. And the {6,6} and {3,3} can be replaced with {6} and {3} respectively. {6,6} means any number of times from 6 to 6. {6} means exactly 6 times.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Gary Wolgast
Greenhorn

Joined: Aug 13, 2002
Posts: 9
Kaustubh G Sharma wrote:Hi I need to validate my string with the following critria ....

[A-Z]{6,6}[A-Z2-9][A-NP-Z0-9]([A-Z0-9]{3,3}){0,1}


how could I do it..?


You can use the java class java.util.regex.Matcher to validate a string to that pattern.
Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1268

Thanks friends...

By the way I did some like below...





 
wood burning stoves
 
subject: validate the string
 
Similar Threads
Regex Help
Regex problem
email validation using java code ."taking space."
regexp on email address
Email Address using java regular expression