• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Matching string with exact number of occurence

 
Arka Sharma
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I tried with all these patters [0-9]{15},[0-9]{15}?, [0-9]{15}+ with same result
 
Arka Sharma
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry to disturb you guys.I as using wrong method find() instead of matches(). Apologize for the mistake
 
Winston Gutkowski
Bartender
Pie
Posts: 10508
64
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic