Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Reg exp help?  RSS feed

 
Andrew Mcmurray
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

I am trying to compile a regular exp that will allow any combination of digits 0-9 OR the work UNKNOWN followed by a : and then any digit combination. This is what I have



Does this look right? It is not working?

Thanks,

AMD
 
Tim LeMaster
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you might be wanting something more like this:

Pattern.compile("((\\d)*|(UNKNOWN)):\\d*");

or if you want to deal with spaces before and after :

Pattern.compile("((\\d)*|(UNKNOWN))\\s*:\\s*\\d*");
 
Andrew Mcmurray
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks that worked!

AMD
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!