On Mon, Apr 1, 2013 at 1:00 AM, Michał Marczyk wrote:
> Could you just preprocess the strings passed to re-pattern (or
> patterns if you're getting those as input) to replace literal newlines
> with escape sequences? I'm assuming you don't care about ?x given the
> result you wish to achieve.
>
T
(The examples from the REPL still apply.)
On 1 April 2013 10:15, Michał Marczyk wrote:
> Oh, wait, I posted the wrong function. Here's the one I meant:
>
> (defn pr-pattern [pat]
> (pr (re-pattern (.replaceAll (re-matcher (re-pattern "\n")
>(.toStrin
Oh, wait, I posted the wrong function. Here's the one I meant:
(defn pr-pattern [pat]
(pr (re-pattern (.replaceAll (re-matcher (re-pattern "\n")
(.toString pat))
"n"
On 1 April 2013 10:00, Michał Marczyk wrote:
On 1 April 2013 07:53, Mark Engelberg wrote:
> Yeah, my goal is simply to get (re-pattern #"a\nb") to print (or more
> precisely, pr) as #"a\nb" without affecting the semantics of printing other
> regular expressions, but that seems to be impossible to achieve. Sigh...
Could you just preprocess
On Sun, Mar 31, 2013 at 10:46 PM, Andy Fingerhut
wrote:
> If you print it as a string, then want to read it back in and convert back
> to a regex, you must read it as a string, then call re-pattern on it. That
> should preserve the original meaning.
>
> Printing it as a string, and trying to read
If you print it as a string, then want to read it back in and convert back
to a regex, you must read it as a string, then call re-pattern on it. That
should preserve the original meaning.
Printing it as a string, and trying to read it as a regex by prepending it
directly with # before the " of th
On Sat, Mar 30, 2013 at 11:33 AM, Mark Engelberg
wrote:
> On Thu, Mar 28, 2013 at 6:36 PM, Andy Fingerhut
> wrote:
>
>> (defn print-regex-my-way [re]
>> (print "#regex ")
>> (pr (str re)))
>>
>> That might be closer to what you want.
>>
>
> Yes. That does the trick. That extra level of conv
On Thu, Mar 28, 2013 at 6:36 PM, Andy Fingerhut wrote:
> (defn print-regex-my-way [re]
> (print "#regex ")
> (pr (str re)))
>
> That might be closer to what you want.
>
Yes. That does the trick. That extra level of converting the regular
expression to a string does the trick because pr "doe
On Thu, Mar 28, 2013 at 7:52 PM, Mikhail Kryshen wrote:
> On Thu, 28 Mar 2013 17:08:46 -0700
> Mark Engelberg 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
On Thu, 28 Mar 2013 17:08:46 -0700
Mark Engelberg 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)^
On Fri, 29 Mar 2013 05:32:52 +0400
Mikhail Kryshen wrote:
> (re-pattern "a\nb") returns regexp pattern that contains the newline
> char literally.
>
> (re-patter "a\\\nb") returns pattern that contains '\n' (two-char
> sequence).
^ should be (re-pattern "a\\nb").
And (re-pattern "a\\\nb") re
On Thu, Mar 28, 2013 at 6:23 PM, Mark Engelberg wrote:
> On Thu, Mar 28, 2013 at 6:16 PM, Andy Fingerhut
> wrote:
>
>> When you say a "sane, readable way", do you mean human-readable, or
>> readable via clojure.core/read or clojure.core/read-string?
>>
>
> I meant human readable
>
>
>>
>> (defn p
(re-pattern "a\nb") returns regexp pattern that contains the newline
char literally.
(re-patter "a\\\nb") returns pattern that contains '\n' (two-char
sequence).
These are not the same. '\n' always matches newline, while literal
newline will be ignored if ?x flag is present.
=> (re-matches (re-p
On Thu, Mar 28, 2013 at 6:16 PM, Andy Fingerhut wrote:
> When you say a "sane, readable way", do you mean human-readable, or
> readable via clojure.core/read or clojure.core/read-string?
>
I meant human readable
>
> (defn print-regex-my-way [re]
> (print "#regex \"" (str re) "\""))
>
If you
On Thu, Mar 28, 2013 at 5:49 PM, Mark Engelberg wrote:
> I'm on 1.5.1 and I get that too, but even though:
> (pr #"a\nb") prints in a sane, readable way
> (pr (re-pattern "a\nb")) does not.
>
> The latter is what I need to print in a nice way.
>
Sorry, I missed that fine point.
When you say a "s
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
>
I'm on 1.5.1 and I get that too, but even though:
(pr #"a\nb") prints in a sane, readable way
(pr (re-pattern "a\nb")) does not.
The latter is what I need to print in a nice way.
On Thu, Mar 28, 2013 at 5:42 PM, Andy Fingerhut wrote:
> On Thu, Mar 28, 2013 at 5:15 PM, Mark Engelberg
> wrote:
On Thu, Mar 28, 2013 at 5:15 PM, Mark Engelberg wrote:
> On Thu, Mar 28, 2013 at 5:08 PM, Mark Engelberg
> wrote:
>
>> However, the first and last example print as:
>> #"a
>> b"
>>
>
> Follow up question:
> Is there any way to make (re-pattern "a\nb") print as #"a\nb"?
>
> I've tried pr, print-du
Look in the Clojure source, file LispReader.java, classes RegexReader and
StringReader for the code that reads strings and regular expressions.
Basically the difference for regular expressions is that since things like
\d to match a single decimal digit, or \s to match a single whitespace
characte
On Thu, Mar 28, 2013 at 5:08 PM, Mark Engelberg wrote:
> However, the first and last example print as:
> #"a
> b"
>
Follow up question:
Is there any way to make (re-pattern "a\nb") print as #"a\nb"?
I've tried pr, print-dup, and various combinations of printing the outputs
of those under with-ou
20 matches
Mail list logo