| Author |
Forward slash and Regex
|
Rajagopal Manohar
Ranch Hand
Joined: Nov 26, 2004
Posts: 183
|
|
Can any one help me understand why this method returns false while I expect it to return true Thanks, Rajagopal
|
 |
Chad Clites
Ranch Hand
Joined: Aug 16, 2005
Posts: 134
|
|
Maybe because it isn't checking the second parameter? You can only check for one expression (as far as I know), unless you are using a true regex expression that will fulfill multiple conditions. But it brings a couple more questions to mind. I would think that would throw a compile time error, because there is no matches method that takes two strings as parameters (at least in the standard API). That leads me to suspect that you are trying to overload the method somehow? Also, since the title of the thread indicates that you are having an issue finding the second string, have you tried altering your code to just look for that particular string and see if it works? [ November 29, 2005: Message edited by: C Clites ]
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24081
|
|
Actually, the method does exist in Tiger (Java 5). I'm not sure why you think this should match, though. The first argument is the regular expression, and it doesn't contain anything to match the "/" (which is not a special character here.) Remember that the "matches" function tries to match the entire sequence, unlike "find", which matches a subsequence. If your regexp were ".enterprise" then it would match.
|
[Jess in Action][AskingGoodQuestions]
|
 |
Chad Clites
Ranch Hand
Joined: Aug 16, 2005
Posts: 134
|
|
Actually, the method does exist in Tiger (Java 5).
Cool.. I was not aware of that. That explains a lot.... /me goes to catch a Tiger
|
 |
Rajagopal Manohar
Ranch Hand
Joined: Nov 26, 2004
Posts: 183
|
|
I'm not sure why you think this should match, though. The first argument is the regular expression, and it doesn't contain anything to match the "/" (which is not a special character here.) Remember that the "matches" function tries to match the entire sequence, unlike "find", which matches a subsequence. If your regexp were ".enterprise" then it would match.
Thanks for the explanation. I'll go back and understand the fundamentals first before I try writing a quick hack with regex the next time -Rajagopal
|
 |
 |
|
|
subject: Forward slash and Regex
|
|
|