Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #18774 > unrolled thread

Unclear about verbose regex syntax (excaping whitespace)

Started byRoy Smith <roy@panix.com>
First post2012-01-10 08:49 -0800
Last post2012-01-10 11:34 -0600
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  Unclear about verbose regex syntax (excaping whitespace) Roy Smith <roy@panix.com> - 2012-01-10 08:49 -0800
    Re: Unclear about verbose regex syntax (excaping whitespace) Tim Chase <python.list@tim.thechases.com> - 2012-01-10 11:34 -0600

#18774 — Unclear about verbose regex syntax (excaping whitespace)

FromRoy Smith <roy@panix.com>
Date2012-01-10 08:49 -0800
SubjectUnclear about verbose regex syntax (excaping whitespace)
Message-ID<27946490.520.1326214183718.JavaMail.geo-discussion-forums@vbnm18>
The docs for re.VERBOSE say, "Whitespace within the pattern is ignored, except when [...] preceded by an unescaped backslash".  It's unclear exactly what that means.  If my pattern is:

<backslash><space><space>

is the second space considered to be preceded by a backslash, and thus taken literally, or does the backslash only apply to the first <space>?  I suspect the latter, but it's somewhat ambiguous.

[toc] | [next] | [standalone]


#18778

FromTim Chase <python.list@tim.thechases.com>
Date2012-01-10 11:34 -0600
Message-ID<mailman.4607.1326220199.27778.python-list@python.org>
In reply to#18774
On 01/10/12 10:49, Roy Smith wrote:
> The docs for re.VERBOSE say, "Whitespace within the pattern is
> ignored, except when [...] preceded by an unescaped
> backslash".  It's unclear exactly what that means.  If my
> pattern is:
>
> <backslash><space><space>
>
> is the second space considered to be preceded by a backslash,
> and thus taken literally, or does the backslash only apply to
> the first<space>?  I suspect the latter, but it's somewhat
> ambiguous.

You're right (easily testable) in your suspicions that the second 
space is ignored in this case.  I suppose the documentation could 
be tweaked to read "immediately preceded".

-tkc



[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web