This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2015年10月30日 10:07 by Pavel, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| issue25517.diff | Elena.Oat, 2016年01月10日 12:09 | review | ||
| Messages (5) | |||
|---|---|---|---|
| msg253725 - (view) | Author: Pavel (Pavel) | Date: 2015年10月30日 10:07 | |
The example advises ".*[.](?!bat$).*$" expression "to match filenames where the extension is not bat". But here is an example which passes such check:
>>> re.match("(.*)[.](?!bat$).*$", "test.a.bat")
<_sre.SRE_Match object at 0x7ff221996f30>
To my mind use of negative lookbehind expressions (not covered so far in the HOWTO) is better:
>>> re.match("(.*)[.].*(?<!.bat)$", "test.a.bat")
>>>
|
|||
| msg253726 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2015年10月30日 11:07 | |
Note that lookbehind assertions still are not documented in Regular Expression HOWTO. The example that demonstrates negative lookahead assertion is ".*[.](?!bat$)[^.]*$". But then we should explain why ".*" is changed to "[^.]*". |
|||
| msg257906 - (view) | Author: Elena Oat (Elena.Oat) * | Date: 2016年01月10日 12:09 | |
Corrected the regular expression and documented why [^.]* is used. |
|||
| msg258032 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2016年01月11日 22:11 | |
New changeset c6b5c03183e3 by Ezio Melotti in branch '2.7': #25517: fix regex in the regex howto. Patch by Elena Oat. https://hg.python.org/cpython/rev/c6b5c03183e3 New changeset 6bd4a4907f66 by Ezio Melotti in branch '3.5': #25517: fix regex in the regex howto. Patch by Elena Oat. https://hg.python.org/cpython/rev/6bd4a4907f66 New changeset 48e2f5915d49 by Ezio Melotti in branch 'default': #25517: merge with 3.5. https://hg.python.org/cpython/rev/48e2f5915d49 |
|||
| msg258033 - (view) | Author: Ezio Melotti (ezio.melotti) * (Python committer) | Date: 2016年01月11日 22:12 | |
Fixed, thanks for the patch! |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:23 | admin | set | github: 69703 |
| 2016年01月11日 22:12:26 | ezio.melotti | set | status: open -> closed resolution: fixed messages: + msg258033 stage: needs patch -> resolved |
| 2016年01月11日 22:11:41 | python-dev | set | nosy:
+ python-dev messages: + msg258032 |
| 2016年01月10日 12:09:29 | Elena.Oat | set | files:
+ issue25517.diff nosy: + Elena.Oat messages: + msg257906 keywords: + patch |
| 2016年01月04日 03:42:46 | ezio.melotti | set | nosy:
+ ezio.melotti, mrabarnett components: + Regular Expressions versions: - Python 3.4 |
| 2015年10月30日 11:07:05 | serhiy.storchaka | set | versions:
- Python 3.2, Python 3.3 nosy: + akuchling, georg.brandl, serhiy.storchaka messages: + msg253726 stage: needs patch |
| 2015年10月30日 10:07:26 | Pavel | create | |