[racket] Regex for blank line?

From: Eli Barzilay (eli at barzilay.org)
Date: Thu Jun 9 01:29:32 EDT 2011

5 hours ago, Richard Lawrence wrote:
> 
> > Both regexps use [^\S\n] to match non-newline whitespace.
> 
> It's handy to know that "\\\n" is the right way to represent a
> newline literal in a regexp.  That wasn't obvious from the
> documentation.

It's not the way to represent literal newlines.  Newlines have no
special meaning in regexps, so you represent them as you would
represent newlines in a string -- with just #rx"\n" (or #px"\n" etc).
It just happens to work as #rx"\\\n" too, because if the literal that
follows a backslash is not a special one, then it matches the literal
itself.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!


Posted on the users mailing list.