On Thursday, March 28, 2013 5:36:45 PM UTC-7, Andy Fingerhut wrote:

>
> I don't understand why (re-pattern "a\\\nb") would match the same thing.  
> I would have guessed that it wouldn't, but it does indeed do so.  For all I 
> know that could be bug or weird dark corner case in the Java regex 
> library.  I would have expected such a regex to match the only the 
> 4-character sequence a,backslash,newline,b.
>
>
That's a string with four characters: a, backslash, newline, b. When the 
regex engine compiles that, it sees the backslash-newline construct as 
"unnecessary escaping" of the newline character: since newline is neither a 
metacharacter nor alphabetic, backslash-newline just matches the single 
character newline.

The j.u.regex.Pattern javadoc, in explaining backslash-quoting, contains: 
"It is an error to use a backslash prior to any alphabetic character that 
does not denote an escaped construct; these are reserved for future 
extensions to the regular-expression language. A backslash may be used 
prior to a non-alphabetic character regardless of whether that character is 
part of an unescaped construct."

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to