On Thu, Mar 28, 2013 at 7:52 PM, Mikhail Kryshen <mikh...@kryshen.net>wrote:
> On Thu, 28 Mar 2013 17:08:46 -0700 > Mark Engelberg <mark.engelb...@gmail.com> wrote: > > > Bug or feature? > > Certainly a feature for complex patterns with whitespace and embedded > comments. > > For example, the following regexp parses line in Combined Log Format used > by Apache httpd and other web servers: > > (def clf-pattern > #"(?x)^ > (\S*)\s # remote host > (\S*)\s # remote logname > (\S*)\s # remote user > \[([^\]]+)\]\s # time the request was received > \"([^\"\\]*(?:\\.[^\"\\]*)*)\"\s # first line of request > (\S*)\s # status > (\S*)\s # size of response in bytes > \"([^\"\\]*(?:\\.[^\"\\]*)*)\"\s # referer > \"([^\"\\]*(?:\\.[^\"\\]*)*)\" # user-agent > \s*$") > > > > I appreciate this information. It's useful to know this subtle difference in how regular expressions store newlines depending on whether it was entered as an actual newline character or an escape sequence designating a newline character, and that this difference manifests when the regex is prepended with (?x). I see how this makes it easier to define a regexp using linebreaks for clarity, and then signaling that those linebreaks are not intended to be taken literally. You probably would not want it to be printed in a single line. > Yes, but I would want it to pr in a single line. This is one of the key differences between print and pr. print is more "human readable" and pr is a more machine-like view of the contents. To me, one of the main things that entails is that whitespace should be printed in a way that you can see exactly what is going on and how it is stored. Compare (pr "abc def") to (print "abc def") then compare (pr #"abc def") to (print #"abc def") I think it is fairly clear that regular expressions *should* behave the same way as strings here, and that pr should be printing whitespaces in a visible, escaped way. Based on everything you've told me, I'd still classify the current behavior as a bug/oversight, not a feature. -- -- 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.