• Post Reply Bookmark Topic Watch Topic
  • New Topic

regex matches  RSS feed

 
Miran Cvenkel
Ranch Hand
Posts: 208
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it does not go into "success", because matches returns false. Why ?

 
Campbell Ritchie
Marshal
Posts: 56529
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you look at the documentation for String#matches() it explains. Your String does not match the given regular expression, which is for one digit only.
 
Rob Spoor
Sheriff
Posts: 21133
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
matches using full String matching. There is no difference if you use "[0-9]" or "^[0-9]$". Add a .* both before and after your regex to get what you want.
 
Miran Cvenkel
Ranch Hand
Posts: 208
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!