Skip to content

Add translation of 9-regular-expressions/02-regexp-character-classes/article.md#675

Merged
leviding merged 5 commits intojavascript-tutorial:masterfrom
bhaltair:master
Apr 11, 2020
Merged

Add translation of 9-regular-expressions/02-regexp-character-classes/article.md#675
leviding merged 5 commits intojavascript-tutorial:masterfrom
bhaltair:master

Conversation

@bhaltair
Copy link
Copy Markdown
Contributor

目标章节:9-regular-expressions/02-regexp-character-classes

当前上游最新 commitjavascript-tutorial/en.javascript.info@162280b

本 PR 所做更改如下:

文件名 参考上游 commit 更改(理由)
article.md javascript-tutorial/en.javascript.info@696eda5 中文翻译

注意,参考上游 commit 是指你所修改的文件,在英文仓库中同名文件的对应 commit,即你此次提交的修改的依据。如果本 PR 你只是提交一个文字或者语句优化,并非根据上游英文仓库的修改而提交的更新,则请填无。

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 24, 2020

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown
Member

@leviding leviding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢提交翻译。有一些标点符号以及相关格式的使用有点小问题,我仅指出了几个代表性的,麻烦根据指出的代表性问题,检查全文并进行修改。修改完成后会进入下一步的 Review 阶段。

辛苦了。

# 字符类

Consider a practical task -- we have a phone number like `"+7(903)-123-45-67"`, and we need to turn it into pure numbers: `79035419441`.
考虑一个实际的任务 -- 我们有一个电话号码,例如 `"+7(903)-123-45-67"`,我们需要将其转换为纯数字: `79035419441`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
考虑一个实际的任务 -- 我们有一个电话号码,例如 `"+7(903)-123-45-67"`,我们需要将其转换为纯数字: `79035419441`
考虑一个实际的任务 我们有一个电话号码,例如 `"+7(903)-123-45-67"`,我们需要将其转换为纯数字:`79035419441`

为此,我们可以查找并删除所有非数字的内容。字符类可以帮助解决这个问题。

A *character class* is a special notation that matches any symbol from a certain set.
*字符类*(Character classes)是一个特殊的符号,匹配特定集中的任何符号。
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
*字符类*(Character classes)是一个特殊的符号,匹配特定集中的任何符号。
**字符类(Character classes)** 是一个特殊的符号,匹配特定集中的任何符号。

*字符类*(Character classes)是一个特殊的符号,匹配特定集中的任何符号。

For the start, let's explore the "digit" class. It's written as `pattern:\d` and corresponds to "any single digit".
首先,让我们探索“数字”类。它写为 `pattern:\d` ,对应于“任何一个数字”。
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
首先,让我们探索“数字”类。它写为 `pattern:\d` ,对应于“任何一个数字”。
首先,让我们探索“数字”类。它写为 `pattern:\d`,对应于“任何一个数字”。

```

Without the flag `pattern:g`, the regular expression only looks for the first match, that is the first digit `pattern:\d`.
如果没有标志 `pattern:g` ,则正则表达式仅查找第一个匹配项,即第一个数字 `pattern:\d`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
如果没有标志 `pattern:g` ,则正则表达式仅查找第一个匹配项,即第一个数字 `pattern:\d`
如果没有标志 `pattern:g`,则正则表达式仅查找第一个匹配项,即第一个数字 `pattern:\d`

`pattern:\d` ("d" is from "digit")
: A digit: a character from `0` to `9`.
`pattern:\d`"d" 来自 "digit"
:数字:从0到9的字符。
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
数字:从0到9的字符。
: 数字:从0到9的字符。

`pattern:\w` ("w" is from "word")
: A "wordly" character: either a letter of Latin alphabet or a digit or an underscore `_`. Non-Latin letters (like cyrillic or hindi) do not belong to `pattern:\w`.
`pattern:\w`"w" 来自 "word"
:“单字”字符:拉丁字母或数字或下划线 `_` 。非拉丁字母(如西里尔字母或印地文)不属于 `pattern:\w`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
“单字”字符:拉丁字母或数字或下划线 `_` 。非拉丁字母(如西里尔字母或印地文)不属于 `pattern:\w`
: “单字”字符:拉丁字母或数字或下划线 `_`。非拉丁字母(如西里尔字母或印地文)不属于 `pattern:\w`

- `pattern:\w` -- Latin letters, digits, underscore `'_'`.
- `pattern:\W` -- all but `pattern:\w`.
- `pattern:.` -- any character if with the regexp `'s'` flag, otherwise any except a newline `\n`.
- `pattern:\d` -- 数字。
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `pattern:\d` -- 数字。
- `pattern:\d` 数字。

- `pattern:.` -- 任何带有 `'s'` 标志的字符, 否则为除换行符 `\n` 之外的任何字符。

...But that's not all!
...但这还不是全部!
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
...但这还不是全部!
……但这还不是全部!

...但这还不是全部!

Unicode encoding, used by JavaScript for strings, provides many properties for characters, like: which language the letter belongs to (if it's a letter) it is it a punctuation sign, etc.
JavaScript用于字符串的Unicode编码提供了许多字符属性,例如:这个字母属于哪一种语言(如果它是一个字母)?它是标点符号吗?等等。
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
JavaScript用于字符串的Unicode编码提供了许多字符属性,例如:这个字母属于哪一种语言(如果它是一个字母)?它是标点符号吗?等等。
JavaScript 用于字符串的 Unicode 编码提供了许多字符属性,例如这个字母属于哪一种语言如果它是一个字母)?它是标点符号吗等等。

JavaScript用于字符串的Unicode编码提供了许多字符属性,例如:这个字母属于哪一种语言(如果它是一个字母)?它是标点符号吗?等等。

We can search by these properties as well. That requires flag `pattern:u`, covered in the next article.
我们也可以通过这些属性进行搜索。这需要标记 `pattern:u` ,在下一篇文章中介绍。
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
我们也可以通过这些属性进行搜索。这需要标记 `pattern:u` ,在下一篇文章中介绍。
我们也可以通过这些属性进行搜索。这需要标记 `pattern:u`,在下一篇文章中介绍。

@javascript-translate-bot
Copy link
Copy Markdown

Please make the requested changes. After it, add a comment "/done".
Then I'll ask for a new review 👻

@bhaltair
Copy link
Copy Markdown
Contributor Author

/done

@javascript-translate-bot javascript-translate-bot requested a review from a team March 24, 2020 04:36
@leviding leviding changed the title Update translation of 9-regular-expressions/02-regexp-character-classes Add translation of 9-regular-expressions/02-regexp-character-classes/article.md Mar 24, 2020
@MartinsYong MartinsYong self-assigned this Apr 4, 2020
Copy link
Copy Markdown
Member

@MartinsYong MartinsYong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

校对完成。感谢翻译~

`pattern:\d` ("d" is from "digit")
: A digit: a character from `0` to `9`.
`pattern:\d`"d" 来自 "digit"
: 数字:从0到9的字符。
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
: 数字:从0到9的字符
: 数字:`0``9` 的字符

## 反向类

For every character class there exists an "inverse class", denoted with the same letter, but uppercased.
对于每个字符类,都有一个“反向类”,用相同的字母表示,但大写。
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
对于每个字符类,都有一个“反向类”,用相同的字母表示,但大写
对于每个字符类,都有一个“反向类”,用相同的字母表示,但要以大写书写形式

```

## A dot is "any character"
## 点是“任何字符”
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## 点是“任何字符”
## 点(.)是匹配“任何字符”

```

### Dot as literally any character with "s" flag
### 点字面意义上是带有"s"标志的任何字符
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### 点字面意义上是带有"s"标志的任何字符
### 带有“s”标志时点字符类严格匹配任何字符


````warn header="Not supported in Firefox, IE, Edge"
Check <https://caniuse.com/#search=dotall> for the most recent state of support. At the time of writing it doesn't include Firefox, IE, Edge.
````warn header="不支持Firefox, IE, Edge"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
````warn header="不支持Firefox, IE, Edge"
````warn header="不支持 Firefox、IE、Edge"

````warn header="Not supported in Firefox, IE, Edge"
Check <https://caniuse.com/#search=dotall> for the most recent state of support. At the time of writing it doesn't include Firefox, IE, Edge.
````warn header="不支持Firefox, IE, Edge"
检查 <https://caniuse.com/#search=dotall> 以获得最新的支持状态。在撰写本文时,它不包括Firefox,IE,Edge
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
检查 <https://caniuse.com/#search=dotall> 以获得最新的支持状态。在撰写本文时,它不包括Firefox,IE,Edge。
使用前可从 <https://caniuse.com/#search=dotall> 确认以获得最新的支持状态。在撰写本文时,它不包括 Firefox、IE、Edge。

```

Let's fix it adding spaces into the regexp `pattern:\d - \d`:
让我们修复它,在regexp模式中添加空格:\ d-\ d`:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
让我们修复它,在regexp模式中添加空格:\ d-\ d`:
让我们修复一下,在正则表达式中添加空格:\ d-\ d`:

但是,如果正则表达式未考虑空格,则可能无法正常工作。

Let's try to find digits separated by a hyphen:
让我们尝试查找由连字符分隔的数字:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
让我们尝试查找由连字符分隔的数字
让我们尝试查找由连字符(-)分隔的数字

JavaScript 用于字符串的 Unicode 编码提供了许多字符属性,例如:这个字母属于哪一种语言(如果它是一个字母)?它是标点符号吗?等等。

We can search by these properties as well. That requires flag `pattern:u`, covered in the next article.
我们也可以通过这些属性进行搜索。这需要标记 `pattern:u`,在下一篇文章中介绍。
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
我们也可以通过这些属性进行搜索。这需要标记 `pattern:u`,在下一篇文章中介绍。
我们也可以通过这些属性进行搜索。这需要标志 `pattern:u`,在下一篇文章中介绍。

@javascript-translate-bot
Copy link
Copy Markdown

Please make the requested changes. After it, add a comment "/done".
Then I'll ask for a new review 👻

@bhaltair
Copy link
Copy Markdown
Contributor Author

bhaltair commented Apr 7, 2020

/done

@leviding leviding merged commit 201bbbe into javascript-tutorial:master Apr 11, 2020
@leviding
Copy link
Copy Markdown
Member

辛苦大家啦~

@leviding leviding added DONE and removed needs +1 labels Apr 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants