• Post Reply Bookmark Topic Watch Topic
  • New Topic

matches  RSS feed

 
meeta gaur
Ranch Hand
Posts: 305
Notepad Tomcat Server Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

false

Why does it return false ? why doesn't it see 1 ?
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
meeta gaur wrote:
false

Why does it return false ? why doesn't it see 1 ?



Perhaps you are confusing the matches() method with the find() method ??

Henry
 
Bruno Candido Volpato da Cunha
Greenhorn
Posts: 18
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:
meeta gaur wrote:
false

Why does it return false ? why doesn't it see 1 ?



Perhaps you are confusing the matches() method with the find() method ??

Henry



Yes, Henry is right.

You want to FIND the digit in your String, not verify if it matches exactly your sentence.
This returns what you expect:





 
meeta gaur
Ranch Hand
Posts: 305
Notepad Tomcat Server Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to all.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!