Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Christopher Arndt Newsgroups: de.comp.lang.python Subject: =?utf-8?q?=5BPython-de=5D_Re=3A_regex=3A_Ausdruck_matches_wen_auf_einer_Zeile=2C_fails_when_=22freespacing=22?= Date: Thu, 8 Dec 2022 09:04:03 +0100 Lines: 15 Message-ID: <0a215c75-fb0d-b27d-b4a1-5a643ec69df0@chrisarndt.de> References: <6bee8c9e-6b66-fc98-9c4d-53f6d162afef@redcor.ch> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de lm8qe5T65b1v+s8mvOV+xwFuJN3ARvRjHoLy+NKQnFNA== Authentication-Results: mail.python.org; dkim=pass reason="2048-bit key; unprotected key" header.d=chrisarndt.de header.i=@chrisarndt.de header.b=J+EQIc0y; dkim-adsp=pass; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisarndt.de; s=dkim; t=1670486644; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qNw7tda/Go566/J0bgt7C9KXsPud+IbeS7k0ay0KnWI=; b=J+EQIc0yJc3VUTsAOg07DLHKq78yXC5wsNAxIPpDABwvBSpNVgXRYmyY3BVgpJN9dZMPCj r9S1SLRW1baUe1VdBz2kDlDFIjFCgDZKTHGJ5VZffE9W92bDvFrnw5DogaTrHPLiboYCrG x2Q1eQi71/xZ9RYy/AyxDMxv/ubLrfInOZ7KFayPBjgzJbZpC57oGr60LS21F7TC69h5DW CG03Br3B5YpV30GTpVoaw5GK65GRU0bAhCiEPdvecJnsWRgIQ85jgMTn5nAKZW7j3mr59b LC/QRaxOASdlJPgOK/4zzyEoQwGes5pZS3GDlXcs1Fzx7ZxgnY4hyR8LDgSNOQ== Content-Language: en-US In-Reply-To: <6bee8c9e-6b66-fc98-9c4d-53f6d162afef@redcor.ch> Authentication-Results: mx1.0x20.eu; auth=pass smtp.mailfrom=chris@chrisarndt.de X-Spamd-Bar: / Message-ID-Hash: YZZ4TDAMGSE5XREKH6XZCRXEABPZ4QVJ X-Message-ID-Hash: YZZ4TDAMGSE5XREKH6XZCRXEABPZ4QVJ X-MailFrom: chris@chrisarndt.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-python-de.python.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.7 Precedence: list List-Id: Die Deutsche Python Mailingliste Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Xref: csiph.com de.comp.lang.python:5916 Am 08.12.22 um 08:20 schrieb robert rottermann: > Muss ich noch irgend ein Flag setzen? a) Du solltest Raw Strings verwenden: regex = r"..." b) Statt "\r\n" zu matchen, verwende re.MULTILINE und "^" und "$". c) Regular expressions sind für so was nur bedingt geeignet, besser wäre es einen Parser zu definieren, z.B. mit PyParsing: https://github.com/pyparsing/pyparsing/blob/master/examples/configParse.py Chris