stdlib-js / stdlib-js/stdlib

docs: difference between `@stdlib/regexp/whitespace` and `\s`?

未关闭
#3,107 8 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
Documentation Help Wanted
主要语言
JavaScript
星标
6k
派生
1.3k
平均合并
1 天 3 小时
30 天内合并 PR
611

描述

### Description

The [doc of regex/whitespace](https://stdlib.io/docs/api/latest/@stdlib/regexp/whitespace) says:

> Returns a [regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) to match a [white space](https://en.wikipedia.org/wiki/Whitespace_character) character.

But [\s does the same thing](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions/Character_classes):

> Matches a single white space character, including space, tab, form feed, line feed, and other Unicode spaces. Equivalent to [\f\n\r\t\v\u0020\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]. For example, /\s\w*/ matches " bar" in "foo bar".

I think an explanation in the doc can be helpful. The git history of the library also doesn't shed any light on the reason. (Perhaps it was created at a time when JS was less powerful?)

### Related Issues

_No response_

### Questions

_No response_

### Demo

_No response_

### Reproduction

```shell

```

### Expected Results

```shell

```

### Actual Results

```shell

```

### Version

_No response_

### Environments

N/A

### Browser Version

_No response_

### Node.js / npm Version

_No response_

### Platform

_No response_

### Checklist

- [x] Read and understood the [Code of Conduct](https://github.com/stdlib-js/stdlib/blob/develop/CODE_OF_CONDUCT.md).
- [x] Searched for existing issues and pull requests.

贡献指南

打开贡献指南

调研方向

Start with the linked @stdlib/regexp/whitespace API documentation and compare its stated behavior with JavaScript's \s character class. Update the documentation to explain the distinction or equivalence, with the work complete when readers can understand why this utility exists; the payload names no source file or test.

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript
领域
documentation
Issue 类型
文档
难度
2/5
预计耗时
1-3 小时
活跃度
停滞
描述清晰度
基本清楚
新手友好度
38/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。