| Author |
Regular Expression string format check.
|
Sanj Sharma
Ranch Hand
Joined: Feb 14, 2004
Posts: 32
|
|
Hi i want to use regular expression for my application. I have some kind of string which i am reading from console and after reading i have to check the parameters of that string like e.x YOU:ME 3,OTHERS 4,EVERYONE 5 So after reading from the console i have string "YOU:ME 3,OTHERS 4,EVERYONE 5" but now from this string i want to check the ranges for ME, OTHERS and EVERYONE (suppose iset range for ME 0-5, OTHERS 0-9 etc.) and also the pattern of the string suppose if someone enter pattern "YOU:My 3,OTHrtrERS 4,EVERYONE 5" on screen i will verify if this is the correct format of string as defined above or not. Can anyone help me here???
|
 |
P Reen
Greenhorn
Joined: Jun 17, 2005
Posts: 2
|
|
Hi, have a look at http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html Also your code should look something like this if ( Pattern.matches("YOU:ME [1-3], OTHERS [0-9], EVERYONE [0-5]", "YOU:ME 3, OTHERS 4, EVERYONE 5")) { System.out.println("Matches"); } else { System.out.println("Does Not Match"); } However this will only match on the correct spacing and lettering ( CAPS )
|
 |
 |
|
|
subject: Regular Expression string format check.
|
|
|