File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Regex.. why isn't this matching? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Regex.. why isn Watch "Regex.. why isn New topic
Author

Regex.. why isn't this matching?

Brad Walton
Ranch Hand

Joined: Feb 16, 2008
Posts: 35
Can't figure out why this isn't matching. It looks ok to me, and works fine when I test in Perl.



Thanks for any help.

Edit: Should have mentioned, I am trying to match on the data between \t and \n.
[ March 06, 2008: Message edited by: Brad Walton ]
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 2778
    
    2
Try using m.find() instead of m.matches(). Find looks for your pattern anywhere within the input string, while matches() only looks to see if it matches the entire string, from beginning to end.
Brad Walton
Ranch Hand

Joined: Feb 16, 2008
Posts: 35
Ehh.. nevermind. Should have been m.find(), not m.matches(). I think it's time to put the keyboard away for the day.

Edit: Thanks Mike, I found the problem and was typing this as you were typing I guess.
[ March 06, 2008: Message edited by: Brad Walton ]
 
I agree. Here's the link: jrebel
 
subject: Regex.. why isn't this matching?
 
Similar Threads
Matches() in Matcher Class
Regular expression to take integers out of a string
matcher.matches()
Regular Expressions (Pattern/Matcher)
find() method in Regex