Open Bug 1318620 Opened 3 years ago Updated 2 years ago

Slightly misleading example

Categories

(Developer Documentation :: JavaScript, defect, P5)

All
Other
defect

Tracking

(Not tracked)

UNCONFIRMED

People

(Reporter: richard.wiseman, Unassigned)

References

()

Details

:: Developer Documentation Request

      Request Type: Correction
     Gecko Version: unspecified
 Technical Contact: 

:: Details

There's an example for x(?!y) on the page:

For example, /\d+(?!\.)/ matches a number only if it is not followed by a decimal point.
/\d+(?!\.)/.exec('3.141') matches "141" but not "3.141".

Whilst this is correct, it's a little misleading because there's an unintended implication that without the (?!\.) part, the pattern would somehow match 3.141 which of course it wouldn't.  Instead, I think the example should be:

For example, /\d+(?!\.)/ matches a number only if it is not followed by a decimal point.
/\d+(?!\.)/.exec('3.141') matches "141" but not "3".
You need to log in before you can comment on or make changes to this bug.