Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > de.comp.lang.python > #4676
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Peter Otten <__peter__@web.de> |
| Newsgroups | de.comp.lang.python |
| Subject | Re: [Python-de] string split |
| Date | Wed, 22 Feb 2017 18:24:18 +0100 |
| Organization | None |
| Lines | 40 |
| Message-ID | <mailman.6.1487784337.2669.python-de@python.org> (permalink) |
| References | <CABTCcybjz2=TpMUvM7ur_obHfx2BGuoF4tohGuipgfrbonLcBA@mail.gmail.com> <o8khfs$ft0$1@blaine.gmane.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="UTF-8" |
| Content-Transfer-Encoding | 8Bit |
| X-Trace | news.uni-berlin.de HB7492ubz/A8Lzi3+ifdhAsuIMiH66BQkLZRKxIHP8Qg== |
| Return-Path | <gcpgg-python-de@m.gmane.org> |
| X-Original-To | python-de@python.org |
| Delivered-To | python-de@mail.python.org |
| X-Injected-Via-Gmane | http://gmane.org/ |
| User-Agent | KNode/4.13.3 |
| X-BeenThere | python-de@python.org |
| X-Mailman-Version | 2.1.23 |
| Precedence | list |
| List-Id | Die Deutsche Python Mailingliste <python-de.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-de>, <mailto:python-de-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-de/> |
| List-Post | <mailto:python-de@python.org> |
| List-Help | <mailto:python-de-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-de>, <mailto:python-de-request@python.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <o8khfs$ft0$1@blaine.gmane.org> |
| X-Mailman-Original-References | <CABTCcybjz2=TpMUvM7ur_obHfx2BGuoF4tohGuipgfrbonLcBA@mail.gmail.com> |
| Xref | csiph.com de.comp.lang.python:4676 |
Show key headers only | View raw
Frank Grellert wrote: > Ich habe ein kniffliges Problem zu lösen: > Ein längerer Text soll in einzelne Sätze aufgespalten werden. Leider > enden nicht alle Sätze am Zeilenende und darüber hinaus enden auch > nicht alle mit einem Punkt. Der Text lautet: > > text = """Dies ist ein Auszug aus einem langen Text: Welche Zeichen > befinden sich am Satzende? > Manchmal ist es ein Ausrufezeichen! Häufig ist es ein Punkt. > """ > Hat jemand eine Idee? Vielleicht experimentierst Du mal mit regulären Ausdrücken, z. B.: >>> import re >>> text = """Dies ist ein Auszug aus einem langen Text: Welche Zeichen ... befinden sich am Satzende? ... Manchmal ist es ein Ausrufezeichen! Häufig ist es ein Punkt. ... """ >>> r = re.compile(r"(.+?[:.!?])(?:\s+|$)", re.DOTALL) >>> for satz in r.findall(text): ... print(repr(satz)) ... 'Dies ist ein Auszug aus einem langen Text:' 'Welche Zeichen\nbefinden sich am Satzende?' 'Manchmal ist es ein Ausrufezeichen!' 'Häufig ist es ein Punkt.' Allerdings: >>> text = "Vielleicht experimentierst Du mal mit regulären Ausdrücken, z. B.:" >>> for satz in r.findall(text): ... print(repr(satz)) ... 'Vielleicht experimentierst Du mal mit regulären Ausdrücken, z.' 'B.:'
Back to de.comp.lang.python | Previous | Next | Find similar
Re: [Python-de] string split Peter Otten <__peter__@web.de> - 2017-02-22 18:24 +0100
csiph-web