aspose file tools*
The moose likes Beginning Java and the fly likes Pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Pattern " Watch "Pattern " New topic
Author

Pattern

Anup Om
Ranch Hand

Joined: Dec 30, 2009
Posts: 62
Hello,

Why wouldn't this compile?


Is it not equivalent to creating a pattern '\' ?

Thanks for help in advance.

EDIT: I am very sorry for a misleading post. The above line of code compiles. But, throws an exception - java.util.regex.PatternSyntaxException: Unexpected internal error near index 1.
Thanks Bear Bibeault.


SCJP6
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

When reporting a compiler error, do you not think it'd be a good idea to include the error message?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Check out any regular expression tutorial regarding the backslash, then consider how Java treats backslashes in strings.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29220
    
135

Anoo Kota wrote:Is it not equivalent to creating a pattern '\' ?

Yes, but that Pattern isn't valid. It says the next character as special meaning and there is no next character.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
Don't get me started about those stupid light bulbs.
 
subject: Pattern
 
Similar Threads
PGJC Exam - clarification?
While Loop Problem
Problem with parallel arrays when sorting in decending order
How To Write Some Text in a Horizontal Rule?
How do I start a web application on an xhtml page?