[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Regex fail?

From: Alex Shinn
Subject: Re: [Chicken-users] Regex fail?
Date: Sun, 1 Nov 2015 22:58:15 +0900

On Fri, Oct 30, 2015 at 10:01 PM, John Cowan <address@hidden> wrote:
Peter Bex scripsit:

> Note the nonl, which the manual states is equivalent to ".", but of
> course nonl means "no newline".

Dot in regular expressions has *always* meant "match any character but a
newline".  It doesn't come up that much in Unix commands, which typically
process their input line by line anyway.  But if you look at the Posix
definition or the Perl one, you see that dot is indeed equivalent to "nonl".
Indeed, "nonl" exists in order to have an SRE equivalent for dot.

> Maybe Alex can give us some info about why this is the case?  I think this
> may have something to do with the multi-line / single-line distinction
> (which, to be honest, I never really understood).

Multi-line and single-line mean totally different things: you can use one
of them or both or neither.  Multi-line mode means that ^ and $ will match
the beginning and end of a line as well as the beginning and the end of
the string.  In non-multi-line mode, they match only the beginning and
the end of the string.  Single-line mode means that dot matches newline;
non-single-line mode means that it does not.

Yes, exactly.  The terminology "single-line" (/s) and "multi-line" (/m)
come from Perl though, and I think are confusing.  But these flags
exist only for PCRE compatibility, so I don't think it's worth changing
them.  With SREs there is no confusion: you always say explicitly
`any' or `nonl', `bol/eol' or `bos/eos'.

Note this is the same in Ruby regexen (which also allows a /m flag).


reply via email to

[Prev in Thread] Current Thread [Next in Thread]