New submission from Brandon <ymbmg...@gmail.com>:

The regular expression used for matching numbers in the documentation for the 
regular expressions module (the tokenizer section) doesn't match the string 
".5", but does match the string "3.".

Here's a link to the tokenizer section of the documentation: 
https://docs.python.org/3/library/re.html#writing-a-tokenizer

The tokenizer example uses r'\d+(\.\d*)?' for matching numbers. I would 
personally match ".5" as a number before I would match "3." as a number. In 
order to do this, I would use r'(\d*\.)?\d+' instead of r'\d+(\.\d*)?'. Python 
3's interpreter matches both "3." and ".5" as numbers when interpreting code, 
so you could use a different regex example for matching both if you wanted to 
be consistent with Python's own interpreter.

----------
components: Regular Expressions
messages: 366801
nosy: TheBrandonGuy, ezio.melotti, mrabarnett
priority: normal
severity: normal
status: open
title: RegEx for numbers in documentation (easy fix - solution provided)
type: behavior
versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue40332>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to