[whatwg/webidl] Decimal regular expression has “dead code” (so to speak) (Issue #1218)

In `/-?(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][+-]?[0-9]+)?|[0-9]+[Ee][+-]?[0-9]+)/`  — _er, wait, I think this will be a little easier to see if we translate to an idiomatic ES pattern first._ In

```js
/-?((\d+\.\d*|\d*\.\d+)(E[+-]?\d+)?|\d+E[+-]?\d+)/i
```

the second `\d*` can only ever match `\d{0,0}`, no digits, because `\d+\.\d*` (`\d{1,}\.\d{0,}`) is inclusive of `\d+\.\d+` (`\d{1,}\.\d{1,}`). As the second `\d*` can only match the empty string here, it seems clearer to not include it:

```js
/-?((\d+\.\d*|\.\d+)(E[+-]?\d+)?|\d+E[+-]?\d+)/i
```

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/webidl/issues/1218

You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/webidl/issues/1218@github.com>

Received on Friday, 14 October 2022 14:43:49 UTC