[issue40332] RegEx for numbers in documentation (easy fix - solution provided)

2020-04-20 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I concur with Mark. It is just an example. The regular expression which would 
support all possible forms of numbers (including exponent, underscores, 
non-decimal numbers) would be more complex and would distract from the main 
goal of the example.

--
nosy: +serhiy.storchaka
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40332] RegEx for numbers in documentation (easy fix - solution provided)

2020-04-20 Thread Mark Dickinson


Mark Dickinson  added the comment:

As you say, isn't this just a personal preference?

Is there an objective reason to prefer something that accepts ".5" and rejects 
"3." over something that rejects ".5" and accepts "3."?

The exact form of numbers accepted seems to be to be irrelevant to the point of 
the example; I'm not sure I see much value in changing it.

--
nosy: +mark.dickinson

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40332] RegEx for numbers in documentation (easy fix - solution provided)

2020-04-19 Thread Brandon


New submission from Brandon :

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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com