File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Matching string with exact number of occurence 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 » Java in General
Bookmark "Matching string with exact number of occurence" Watch "Matching string with exact number of occurence" New topic
Author

Matching string with exact number of occurence

Arka Sharma
Ranch Hand

Joined: Jun 15, 2011
Posts: 103

Hi,

I need to mach the pattern a string containing digits between 0 to 9 and the length is 15.Actually I want to check if an IMSI is valid or not.So I am using the folllowing code

It works fine if the length is less that 15 that is it sets valid to false but if the length is more than 15 let say 16,17 then it sets valid to true

Regards,
Arka
Arka Sharma
Ranch Hand

Joined: Jun 15, 2011
Posts: 103

I tried with all these patters [0-9]{15},[0-9]{15}?, [0-9]{15}+ with same result
Arka Sharma
Ranch Hand

Joined: Jun 15, 2011
Posts: 103
Sorry to disturb you guys.I as using wrong method find() instead of matches(). Apologize for the mistake
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7014
    
  16

Arka Sharma wrote:Sorry to disturb you guys.I as using wrong method find() instead of matches(). Apologize for the mistake

No probs. And the actual problem is that you're using '$' without '^'. If you'd had both, then find() would have worked as well.

I leave you to work out why.

Winston

Isn't it funny how there's always time and money enough to do it WRONG?
Artlicles by Winston can be found here
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Matching string with exact number of occurence
 
Similar Threads
How to monitor sim card is changed?
Checking SSN without regular expressions
Java Letter/Number counter
Why doesn't this match?
How to Convert HQL to SQL Query