aspose 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
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: 8008
    
  22

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?
Articles by Winston can be found here
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Matching string with exact number of occurence