Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <mailman.9.1728414704.4695.python-list@python.org>
Deutsch   English   Français   Italiano  
<mailman.9.1728414704.4695.python-list@python.org>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!feeds.phibee-telecom.net!2.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: MRAB <python@mrabarnett.plus.com>
Newsgroups: comp.lang.python
Subject: Re: Correct syntax for pathological re.search()
Date: Tue, 8 Oct 2024 20:11:40 +0100
Lines: 19
Message-ID: <mailman.9.1728414704.4695.python-list@python.org>
References: <ve0o34$1nep4$1@dont-email.me>
 <c56c0689-e248-488f-af52-e9de2a454318@mrabarnett.plus.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de SkuT7v7KAJdq/XgxaLZHVQIkwPAHFup40hqMS5MrK89w==
Cancel-Lock: sha1:CG0tBkJeplBqwoBy14W0a1bCK/I= sha256:/Kle2zLZCou0brsjzxtDhHbMA98TbR/dKrfhXHTXlR8=
Return-Path: <python@mrabarnett.plus.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
 reason="2048-bit key; unprotected key"
 header.d=plus.com header.i=@plus.com header.b=nFyfPcpB;
 dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.006
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '(which': 0.04; 'string':
 0.07; 'from:addr:python': 0.09; 'received:192.168.1.64': 0.09;
 'regex': 0.09; 'syntax': 0.15; 'backslash': 0.16; 'discard': 0.16;
 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16;
 'literals': 0.16; 'message-id:@mrabarnett.plus.com': 0.16;
 'received:plus.net': 0.16; 'subject:syntax': 0.16; 'wrote:': 0.16;
 'uses': 0.19; 'to:addr:python-list': 0.20; 'lines': 0.23;
 'coming': 0.27; 'header:User-Agent:1': 0.30; 'python-list': 0.32;
 'received:192.168.1': 0.32; 'but': 0.32; "i'm": 0.33;
 'subject:for': 0.33; 'header:In-Reply-To:1': 0.34; 'trying': 0.35;
 'those': 0.36; 'received:192.168': 0.37; 'means': 0.38; 'use':
 0.39; 'michael': 0.60; 'received:212': 0.62; 'once': 0.63; 'skip:r
 20': 0.64; 'right': 0.68; 'through.': 0.69; 'left': 0.83
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plus.com; s=042019;
 t=1728414701; bh=GowGM2hjwwMafa/LMO7yHDqY+SziUxpndafD2zXvtCg=;
 h=Date:Subject:To:References:From:In-Reply-To;
 b=nFyfPcpBJ3+RDr/OYfsRxHs5mk5sBGZ1GN4maSVXkO0BUyzCe/08GCRlgtPRbgIZe
 4lyd2/d7JI4JQ4Sys2prUXnQkqkzzJ3LM6lfW8zyz7IxxuTnsqgT8IKviMvp8cP2gd
 Dpga3CkMLM6VJZsWLFy65zQrTuX7paeZpa2MgH8M8H/Do+T3bM81CHitc5RGDxYOYc
 vBVLTL/4V0sAUphXQUN/Rk3OOAU++LkoMz7yLt9TkuqJ3wtpf2WChIy1etJ15nf4la
 FErTnu/fb2XzAL7QoHnvtp1ebRKZRorxBAERf8FPzG7pdZO/HgLeBAXcK7GcRAXCEz
 DNlnLZhdzQPBw==
X-Clacks-Overhead: "GNU Terry Pratchett"
X-CM-Score: 0.00
X-CNFS-Analysis: v=2.4 cv=GMarEfNK c=1 sm=1 tr=0 ts=670583ed
 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17
 a=IkcTkHD0fZMA:10 a=ldp9Uc8XTLB9PhiD4Q0A:9 a=QEXdDO2ut3YA:10
X-AUTH: mrabarnett@:2500
User-Agent: Mozilla Thunderbird
Content-Language: en-GB
In-Reply-To: <ve0o34$1nep4$1@dont-email.me>
X-CMAE-Envelope: MS4xfAWKoO4b9W3LiH+OQ402MkRtn1hWwvZzpZVx3SqYGhW54HNiY/adpU3Y5QfwUCklZjxpfdR6CKQRUf31M67u45W6shfYGirRuzPmJprMcncKAQUQ+n3B
 BDFE4LLrZjUgCPOuEqPoGMWUT6EAGJqP4ezaF3z2VG29NZNhptDpJ1S/3h+AxGaBowQ9u5wpW+BCMr7yrsC0lr9iIDdOMMvAd04=
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
 <python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
 <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
 <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <c56c0689-e248-488f-af52-e9de2a454318@mrabarnett.plus.com>
X-Mailman-Original-References: <ve0o34$1nep4$1@dont-email.me>
Bytes: 4797

On 2024-10-07 14:35, Michael F. Stemper via Python-list wrote:
> I'm trying to discard lines that include the string "\sout{" (which is TeX, for
> those who are curious. I have tried:
>     if not re.search("\sout{", line):
>     if not re.search("\sout\{", line):
>     if not re.search("\\sout{", line):
>     if not re.search("\\sout\{", line):
> 
> But the lines with that string keep coming through. What is the right syntax to
> properly escape the backslash and the left curly bracket?
> 
String literals use backslash is an escape character, so it needs to be 
escaped, or you need to use a "raw" string.

However, regex also uses backslash as an escape character.

That means that a literal backslash in a regex that's in a plain string 
literal needs to be doubly-escaped, once for the string literal and 
again for the regex.