-
Notifications
You must be signed in to change notification settings - Fork 735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect regex for floating point numbers #2711
Comments
From manual page: https://www.php.net/manual/en/language.types.float.php Fixed Issue php#2711
I actually think the REGEX can be simplified further to this:
Which might make it a bit easier to read |
This doesn't seem to accept |
You're right. But You can check this code:
|
This looks correct, can you make a PR? |
Sorry to jump in here at the last minute, but I'd like to offer an alternative opinion on this. I believe the purpose of this section of the documentation is to describe the structure of a PHP float literal. The description doesn't need to be useful for other purposes (eg. input validation) and it doesn't need to be a valid PCRE regular expression. The grammar used by the PHP lexer is:
The above grammar or something derived from it should be used to correct the documentation. While obviously correct, it is unclear:
To clarify the above grammar and for consistency with the integer documentation, I offer the following alternative:
For me, the above grammar is easier to read and therefore better achieves the purpose I've described for the documentation, but I'd like to hear other thoughts. |
Your description of the floating point number format would be ideal for documentation. I would choose this description. |
People, if you have suggestions, you can just send a PR. |
Done! :) |
Do I need to submit a PR for documentation in other languages? |
You can, but this change is tracked via our RevCheck for all the languages via: http://doc.php.net |
Fixed via #2967 |
From manual page: https://www.php.net/manual/en/language.types.float.php
Hi! I think the regex for floating point numbers is wrong.
Please, replace
DNUM ([0-9]*(_[0-9]+)*[\.]{LNUM}) | ({LNUM}[\.][0-9]*(_[0-9]+)*)
with
DNUM (([0-9]+(_[0-9]+)*)?\.{LNUM}) | ({LNUM}\.([0-9]+(_[0-9]+)*)?)
The regex specified in the documentation accepts such numbers as correct, but they are incorrect:
_123.456
123._456
And need to fix this article in all languages. Thanx!
The text was updated successfully, but these errors were encountered: