Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > de.comp.lang.python > #4499
| From | Stefan Behnel <python-de@behnel.de> |
|---|---|
| Newsgroups | de.comp.lang.python |
| Subject | Re: [Python-de] re.split und Unicode in Python 3 |
| Date | 2016-07-29 16:57 +0200 |
| Message-ID | <mailman.28.1469804610.6033.python-de@python.org> (permalink) |
| References | <7ae0837f-8596-a55b-7195-e6d85492dd51@chrisarndt.de> <7ce4398d-3c64-f8a5-8d41-7213bc0437d4@behnel.de> |
Christopher Arndt schrieb am 29.07.2016 um 16:45:
> Ich habe gerade dieses merkwürdige Verhalten von Python 3.5 festgestellt:
>
>
> Python 3.5.1+ (default, Mar 30 2016, 22:46:26)
> [GCC 5.3.1 20160330] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import re
> >>> s = 'One\u2003Two'
>
>
> >>> re.search('\s+', s)
> <_sre.SRE_Match object; span=(3, 4), match='\u2003'>
> >>> re.search('\s+', s, re.ASCII)
> >>>
> ^^^ # --> No match
>
> >>> re.split('\s+', s)
> ['One', 'Two']
> >>> re.split('\s+', s, re.ASCII)
> ['One', 'Two']
>
> Bug?
Nein.
>>> re.split('\s+', s, flags=re.ASCII)
['One\u2003Two']
Die Signatur von re.split() ist
re.split(pattern, string, maxsplit=0, flags=0)
https://docs.python.org/3/library/re.html#re.split
Stefan
Back to de.comp.lang.python | Previous | Next | Find similar
Re: [Python-de] re.split und Unicode in Python 3 Stefan Behnel <python-de@behnel.de> - 2016-07-29 16:57 +0200
csiph-web