Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Matching string with exact number of occurence  RSS feed

 
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
 
Bartender
Posts: 10575
66
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
 
I love a good mentalist. And so does this tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!