fix(guide): simplify directory structure

This commit is contained in:
Mrugesh Mohapatra
2018-10-16 21:26:13 +05:30
parent f989c28c52
commit da0df12ab7
35752 changed files with 0 additions and 317652 deletions

View File

@@ -0,0 +1,9 @@
---
title: Check for All or None
localeTitle: 检查全部或无
---
## 检查全部或无
这是一个存根。 [帮助我们的社区扩展它](https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/javascript-algorithms-and-data-structures/regular-expressions/check-for-all-or-none/index.md) 。
[这种快速风格指南有助于确保您的拉取请求被接受](https://github.com/freecodecamp/guides/blob/master/README.md) 。

View File

@@ -0,0 +1,26 @@
---
title: Extract Matches
localeTitle: 提取匹配
---
## 提取匹配
使用`match()`方法,您可以提取与正则表达式匹配的字符串部分。在此挑战中,您将从提供的字符串中提取“编码”一词。
## 提示1
更改正则表达式以检测“编码”一词。
## 提示2
你在字符串上调用`match()`方法了吗?
## 剧透警报 - 提前解决!
## 解:
```javascript
let extractStr = "Extract the word 'coding' from this string.";
let codingRegex = /coding/;
let result = extractStr.match(codingRegex);
```

View File

@@ -0,0 +1,18 @@
---
title: Find Characters with Lazy Matching
localeTitle: 查找具有延迟匹配的字符
---
## 查找具有延迟匹配的字符
#### Challange
修复regex `/<.*>/`以返回HTML标记`<h1>`而不是文本`<h1>Winter is coming</h1>` 。记住通配符。在正则表达式中匹配任何字符。
#### 解:
```js
let text = "<h1>Winter is coming</h1>";
let myRegex = /<h1>?/; // it's the answer!
let result = text.match(myRegex);
```

View File

@@ -0,0 +1,26 @@
---
title: Find More Than the First Match
localeTitle: 找到比第一场比赛更多的东西
---
## 找到比第一场比赛更多的东西
如果在字符串中出现多次正则表达式,则可以使用`match()`函数来检测所有这些。只需在正则表达式末尾的`g`标记处标记!这就是你在这次挑战中所做的。
## 提示1
更改正则表达式以便它检测到单词“twinkle”。
## 提示2
您可以为正则表达式添加多个标签!例如,检测多次出现并且无论如何都检测到的正则表达式可以被构造为`gi``ig`
## 剧透警报 - 提前解决!
## 解
```javascript
let twinkleStar = "Twinkle, twinkle, little star";
let starRegex = /twinkle/gi;
let result = twinkleStar.match(starRegex);
```

View File

@@ -0,0 +1,41 @@
---
title: Find One or More Criminals in a Hunt
localeTitle: 在狩猎中找到一个或多个罪犯
---
## 在狩猎中找到一个或多个罪犯
## 问题
一群罪犯逃出监狱逃跑,但你不知道有多少人。但是,你知道他们和其他人在一起时会保持紧密联系。你有责任立刻找到所有的罪犯。
写一个贪婪的正则表达式在一群其他人中找到一个或多个罪犯。罪犯由大写字母C代表。
### 提示1
你是用斜线围绕你的正则表达式吗?
```javascript
let regexp = /t.[az]*t/;
```
### 提示2
你在正则表达式中使用'+'标志?
```javascript
let regexp = /E+/; // returns E, EE, EEE patterns
```
### 扰流板警告 - 提前解决
## 解
```javascript
let crowd = 'P1P2P3P4P5P6CCCP7P8P9';
let reCriminals = /C+/; // Change this line
let matchedCriminals = crowd.match(reCriminals);
console.log(matchedCriminals);
```

View File

@@ -0,0 +1,22 @@
---
title: Ignore Case While Matching
localeTitle: 匹配时忽略大小写
---
## 匹配时忽略大小写
创建正则表达式时,您可能希望匹配拼写相同但字符串不同的字符串部分。为此,您将`i`标志添加到正则表达式的末尾。在这个挑战中,你就是这么做的。
## 提示1
修改正则表达式使其检测到“freeCodeCamp”“FREECODECAMP”和“FrEeCoDeCaMp”。也许使用`i`旗可能有帮助吗?
## 剧透警报 - 提前解决!
## 解
```javascript
let myString = "freeCodeCamp";
let fccRegex = /freeCodeCamp/i;
let result = fccRegex.test(myString);
```

View File

@@ -0,0 +1,11 @@
---
title: Regular Expressions
localeTitle: 常用表达
---
## 常用表达
这是一个存根。 [帮助我们的社区扩展它](https://github.com/freecodecamp/guides/tree/master/src/pages/mathematics/quadratic-equations/index.md) 。
[这种快速风格指南有助于确保您的拉取请求被接受](https://github.com/freecodecamp/guides/blob/master/README.md) 。
#### 更多信息:

View File

@@ -0,0 +1,22 @@
---
title: Match a Literal String with Different Possibilities
localeTitle: 匹配具有不同可能性的文字字符串
---
## 匹配具有不同可能性的文字字符串
假设您想要将许多不同的单词与正则表达式匹配;使用`|`符号,这成为可能。在这个挑战中,您使用该符号来识别隐藏在字符串中的四种不同的宠物!
## 提示1
在字符串文字内,放置宠物名称,每个名称由`|`分隔符号。
## 剧透警报 - 提前解决!
## 解:
```javascriot
let petString = "James has a pet cat.";
let petRegex = /dog|cat|bird|fish/;
let result = petRegex.test(petString);
```

View File

@@ -0,0 +1,13 @@
---
title: Match All Letters and Numbers
localeTitle: 匹配所有字母和数字
---
问题 使用速记字符类\\ w来计算各种引号和字符串中的字母数字字符数。
解 让quoteSample =“五个拳击向导快速跳跃。”; 让alphabetRegexV2 = / \\ w / gi; //改变这一行 let result = quoteSample.matchalphabetRegexV2.length;
## 匹配所有字母和数字
这是一个存根。 [帮助我们的社区扩展它](https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/javascript-algorithms-and-data-structures/regular-expressions/match-all-letters-and-numbers/index.md) 。
[这种快速风格指南有助于确保您的拉取请求被接受](https://github.com/freecodecamp/guides/blob/master/README.md) 。

View File

@@ -0,0 +1,25 @@
---
title: Match All Non-Numbers
localeTitle: 匹配所有非数字
---
## 匹配所有非数字
## 提示1
* 您应该尝试使用全局标志。
## 提示2
* 尝试使用非数字字符的速记字符。
# 扰流警报!!提前解决!
## 解
```javascript
let noNumRegex = /\D/g;
```
## 说明
* `\D`速记字符用于匹配非数字字符,它与使用`[^0-9]`具有相同的结果;

View File

@@ -0,0 +1,25 @@
---
title: Match All Numbers
localeTitle: 匹配所有号码
---
## 匹配所有号码
## 提示1
* 全球旗帜将帮助您度过这一挑战。
## 提示2
* 尝试使用`d` igits的速记字符。
# 扰流警报!!提前解决!
## 解
```javascript
let numRegex = /\d/g;
```
## 说明
* `\d`简写字符是`[0-9]`的快捷方式它搜索0到9之间的任何数字。

View File

@@ -0,0 +1,25 @@
---
title: Match Anything with Wildcard Period
localeTitle: 匹配通配符期间的任何内容
---
## 匹配通配符期间的任何内容
## 提示1
`.`是这一挑战的关键。
## 提示2
你应该把点放在正确的位置。
## 解
```javascript
let exampleStr = "Let's have fun with regular expressions!";
let unRegex = /.un/; // Change this line
let result = unRegex.test(exampleStr);
```
## 释
这段时期`.`将是任何一个字符因此字符串“run”“sun”“fun”和“pun”具有相同的un charaters。

View File

@@ -0,0 +1,33 @@
---
title: Match Beginning String Patterns
localeTitle: 匹配开始字符串模式
---
## 匹配开始字符串模式
## 问题
使用正则表达式中的插入符号只能在字符串rickyAndCal的开头找到“Cal”。
### 提示1
尝试用斜杠包围你的正则表达式
```javascript
let testExp = /^test/;
// returns true or false depending on whether test is found in the beginning of the string
```
### 提示2
尝试在括号外使用'^'字符插入符号,如上例所示
### 扰流警报 - 提前解决
## 解
```javascript
let rickyAndCal = "Cal and Ricky both like racing.";
let calRegex = /^Cal/; // Change this line
let result = calRegex.test(rickyAndCal);
```

View File

@@ -0,0 +1,9 @@
---
title: Match Characters that Occur One or More Times
localeTitle: 匹配出现一次或多次的字符
---
## 匹配出现一次或多次的字符
问题: 您希望在“密西西比”中字母s出现一次或多次时找到匹配项。写一个使用+符号的正则表达式。 解决方案
let difficultSpelling =“Mississippi”; 让myRegex = / s + / g; //这是解决方案 let result = difficultSpelling.matchmyRegex;

View File

@@ -0,0 +1,30 @@
---
title: Match Characters that Occur Zero or More Times
localeTitle: 匹配出现零次或多次的字符
---
## 匹配出现零次或多次的字符
正则表达式中后跟`*`任何字母都不必出现在测试的字符串中,而正则表达式中后跟`+`任何字母必须至少出现一次字符串,如下所示,
```javascript
let phrase = "ba humbug";
let regexPlus = /bah+/;
let regexStar = /bah*/;
regexPlus.test(phrase); // returns false
regexStar.test(phrase); // returns true
```
两者都允许连续出现任意数量的相同字母,例如
```javascript
let phrase = "wooooow look at that!";
let regexPlus = /wo+w/;
let regexStar = /wo*w/;
regexPlus.test(phrase); // returns true
regexStar.test(phrase); // returns true
```

View File

@@ -0,0 +1,9 @@
---
title: Match Ending String Patterns
localeTitle: 匹配结束字符串模式
---
## 匹配结束字符串模式
这是一个存根。 [帮助我们的社区扩展它](https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/javascript-algorithms-and-data-structures/regular-expressions/match-ending-string-patterns/index.md) 。
[这种快速风格指南有助于确保您的拉取请求被接受](https://github.com/freecodecamp/guides/blob/master/README.md) 。

View File

@@ -0,0 +1,9 @@
---
title: Match Everything But Letters and Numbers
localeTitle: 匹配一切,但字母和数字
---
## 匹配一切,但字母和数字
这是一个存根。 [帮助我们的社区扩展它](https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/javascript-algorithms-and-data-structures/regular-expressions/match-everything-but-letters-and-numbers/index.md) 。
[这种快速风格指南有助于确保您的拉取请求被接受](https://github.com/freecodecamp/guides/blob/master/README.md) 。

View File

@@ -0,0 +1,26 @@
---
title: Match Letters of the Alphabet
localeTitle: 匹配字母的字母
---
## 匹配字母的字母
在此挑战中,要求您匹配给定字符串中的所有字母。您不仅要匹配/搜索这些字符,还要求您提取它们。
### 提示1
请记住,您被要求从字符串中提取字母 - 这不能通过.test方法完成因为它返回True或False。在这种情况下我们需要使用.match方法从字符串中提取实际结果。
### 提示2
你是否使用带括号的match方法字符大小写标志例如regExp = / \[ae\] / vs regExp = / ae /。这允许我们做的是使用简写符号/ \[ae\] /在字符串中搜索与\[abc... e\]匹配的任何字符。
### 扰流板警报:未来的解决方案
## 解
```javascript
let quoteSample = "The quick brown fox jumps over the lazy dog.";
let alphabetRegex = /[az]/ig; // Change this line
let result = quoteSample.match(alphabetRegex); // Change this line
```

View File

@@ -0,0 +1,24 @@
---
title: Match Literal Strings
localeTitle: 匹配文字字符串
---
## 匹配文字字符串
这一挑战与以往没有任何不同;但在这种情况下,您将了解到字符串文字区分大小写。这意味着,当您测试一个字符串是否有文字时,它将搜索字符串中的确切大小写(下部或上部)。在即将到来的课程中,您将学习如何查找字符串文字,无论其大小写如何。
在这个挑战中,你发现了一个字符串!
## 提示1
将行更改为具有正确的字符串文字。
## 剧透警报 - 提前解决!
## 解:
```javascript
let waldoIsHiding = "Somewhere Waldo is hiding in this text.";
let waldoRegex = /Waldo/; // Change this line
let result = waldoRegex.test(waldoIsHiding);
```

View File

@@ -0,0 +1,9 @@
---
title: Match Non-Whitespace Characters
localeTitle: 匹配非空白字符
---
## 匹配非空白字符
这是一个存根。 [帮助我们的社区扩展它](https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/javascript-algorithms-and-data-structures/regular-expressions/match-non-whitespace-characters/index.md) 。
[这种快速风格指南有助于确保您的拉取请求被接受](https://github.com/freecodecamp/guides/blob/master/README.md) 。

View File

@@ -0,0 +1,40 @@
---
title: Match Numbers and Letters of the Alphabet
localeTitle: 匹配数字和字母的字母
---
## 匹配数字和字母的字母
在此挑战中系统会要求您返回从字符串中提取的数字和字母的集合。我们的目标是创建一个单一的正则表达式捕获h和s之间的字母范围以及2到6之间的数字。
### 提示1
你在使用match方法吗如果是这样那么你是否从适当的变量调用方法
```javascript
let input_string = "The string you are testing on"
let yourRegExp = /[hs]/;
let correct_result = input_string.match(yourRegExp); // passes - returns characters H to S
let incorrect_result = yourRegExp.match(input_string); // fails - .match() is not a function
```
### 提示2
您是否记得启用正则表达式标志例如“i”表示忽略大小写而“g”表示是否可以检索多个值如果是这样那么你是否包括数字和字母的字符大小写匹配
```javascript
let regexp = /[a-z1-100]/ig
// above code returns all characters from A to Z, along with all numbers from 1 to 100
// this includes the letter A and Z and the numbers 1 and 100
```
### 扰流警报 - 提前解决
## 解
```javascript
let quoteSample = "Blueberry 3.141592653s are delicious.";
let myRegex = /[h-s2-6]/ig; // Change this line
let result = quoteSample.match(myRegex); // Change this line
```

View File

@@ -0,0 +1,28 @@
---
title: Match Single Character with Multiple Possibilities
localeTitle: 将单个角色与多种可能性相匹配
---
## 将单个角色与多种可能性相匹配
### 提取
使用match方法您可以提取与正则表达式匹配的字符串部分。在此挑战中您将从提供的字符串中提取元音“aeiou”。
### 提示1
您是否尝试使用test方法请记住此方法仅返回True或False - 我们需要从字符串中提取元音。
### 提示2
您是否尝试过不使用逗号的“\[\]”字符大小写匹配?即\[abcd\] vs \[abcd\]
### 剧透警报 - 提前解决!
## 解
```javascript
let quoteSample = "Beware of bugs in the above code; I have only proved it correct, not tried it.";
let vowelRegex = /[aeiou]/ig; // Change this line
let result = quoteSample.match(vowelRegex); // Change this line
```

View File

@@ -0,0 +1,40 @@
---
title: Match Single Characters Not Specified
localeTitle: 匹配未指定的单个字符
---
## 匹配未指定的单个字符
在此挑战中,我们被要求返回未完全指定的匹配集合。虽然之前的正则表达式挑战会在字符情况\[az\]中匹配,但此挑战要求我们使用插入符\[^ az\]来否定这些匹配。我们的目标是返回一个非元音或数字的否定集合(不匹配)。
## 提示1
你还记得用括号和斜线包围你的正则表达式吗?
```javascript
let exampleRegExp = /[^az]/;
```
如果是这样,那么仔细检查你是否正在添加适当的标志:
* i忽略搜索/匹配的大小写
* g检索多个值; default设置为返回遇到的第一个匹配项
* ^:取消此标志后的匹配
### 提示2
一定要检查你的号码范围是否正确 - 挑战要求我们否定0-99之间的所有数字。这可以使用在正则表达式的第一个开始括号后立即放置的否定插入符来完成。
```javacsript
let numbersRegExp = /[^0-99]/ig;
```
### 扰流警报 - 提前解决
## 解
```javascript
let quoteSample = "3 blind mice.";
let myRegex = /[^aeiou^0-99]/ig; // Change this line
let result = quoteSample.match(myRegex); // Change this line
```

View File

@@ -0,0 +1,9 @@
---
title: Match Whitespace
localeTitle: 匹配空白
---
## 匹配空白
这是一个存根。 [帮助我们的社区扩展它](https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/javascript-algorithms-and-data-structures/regular-expressions/match-whitespace/index.md) 。
[这种快速风格指南有助于确保您的拉取请求被接受](https://github.com/freecodecamp/guides/blob/master/README.md) 。

View File

@@ -0,0 +1,19 @@
---
title: Positive and Negative Lookahead
localeTitle: 积极和消极的前瞻
---
## 积极和消极的前瞻
* 记得使用2个`lookaheads`来检查字符串中的模式。第一个`lookahead`与示例中给出的非常相似 - '= \\ w {3,6}' - 只有`lower-number` 3对于我们的测试用例来说太低了并且`upper-number`是完全不必要的。第一个`lookahead`仅用于查找由一定数量的字符组成的字符串。必须使用第二个`lookahead`来检查字符串末尾的连续数值。
* 第二个`lookahead`也类似于示例中给出的 - `(?=\D*\d)` - 但是,也必须修改此表达式以传递所有测试用例。请记住指定要在字符串末尾显示的确切数字量。
## 方案:
```javascript
let sampleWord = "astronaut";
let pwRegex = /(?=\w{5,})(?=\D*\d{2})/;
let result = pwRegex.test(sampleWord);
```

View File

@@ -0,0 +1,26 @@
---
title: Remove Whitespace from Start and End
localeTitle: 从开始和结束中删除空格
---
## 从开始和结束中删除空格
要解决此挑战,您只需创建一个正则字符串字符串,该字符串匹配字符串开头或结尾处的任何空格。
## 提示1
想一想如何在字符串的开头或结尾选择子字符串。
## 提示2
想想你如何选择空格
## 剧透警报 - 提前解决!
## 解:
```javascript
let hello = " Hello, World! ";
let wsRegex = /^\s+|\s+$/g; // Change this line
let result = hello.replace(wsRegex, ''); // Change this line
```

View File

@@ -0,0 +1,34 @@
---
title: Restrict Possible Usernames
localeTitle: 限制可能的用户名
---
## 限制可能的用户名
## 解:
```javascript
let username = "JackOfAllTrades";
let userCheck = /^[az]{2,}\d*$/i;
let result = userCheck.test(username);
```
## 说明:
1. 用户名中唯一的数字必须在最后。 `\d$` 最后可以有零个或多个。 `*`
```javascript
/\d*$/;
```
2. 用户名字母可以是小写和大写。 `i`
```javascript
/\d*$/i;
```
3. 用户名长度必须至少为两个字符。 `{2,}` 双字母用户名只能使用字母字母。 `^[az]`
```javascript
/^[az]{2,}\d*$/i;
```

View File

@@ -0,0 +1,61 @@
---
title: Reuse Patterns Using Capture Groups
localeTitle: 使用捕获组重用模式
---
## 使用Capture Group重用模式
## 提示1
给出以下代码:
```javascript
let testString = "test test test ";
let reRegex =/(test)\s\1/;
let result = reRegex.test(testString);
```
`result`将仅匹配`test test`因为此示例中的`\1`代表与最近匹配的第一个捕获组`(test)`相同的文本。
如果我们要正面翻译正则表达式,它看起来像这样:
```js
let re = /(test)\s\1;
let literalRe = /test\stest;
```
`rea``literalRe`都会匹配相同的东西。
## 提示2
鉴于以下代码:
```javascript
let testString = "test test test ";
let reRegex =/(test)(\s)\1\2\1/;
let result = reRegex.test(testString);
```
将匹配整个`test test test`因为: `\1`重复(测试) `\2`重复(\\ s
## 提示3
代码如下:
```javascript
let testString = "test test test test test test";
let reRegex =/(test)(\s)\1\2\1/g;
let result = reRegex.test(testString);
```
因为我们使用了`\g` ,我们的正则表达式在第一次完全匹配( `test test test` )之后没有返回并匹配所有重复。
## 剧透警报 - 提前解决!
## 解:
```javascript
let repeatNum = "42 42 42";
let reRegex = /^(\d+)\s\1\s\1$/;
let result = reRegex.test(repeatNum);
```

View File

@@ -0,0 +1,9 @@
---
title: Specify Exact Number of Matches
localeTitle: 指定完全匹配数
---
## 指定完全匹配数
这是一个存根。 [帮助我们的社区扩展它](https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/javascript-algorithms-and-data-structures/regular-expressions/specify-exact-number-of-matches/index.md) 。
[这种快速风格指南有助于确保您的拉取请求被接受](https://github.com/freecodecamp/guides/blob/master/README.md) 。

View File

@@ -0,0 +1,13 @@
---
title: Specify Only the Lower Number of Matches
localeTitle: 仅指定较低的匹配数
---
问题 只有当它有四个或更多字母z时才更改正则表达式haRegex以匹配单词“Hazzah”。
解 让haStr =“Hazzzzah”; 让haRegex = / Haz {4,30}啊/; //改变这一行 let result = haRegex.testhaStr;
## 仅指定较低的匹配数
这是一个存根。 [帮助我们的社区扩展它](https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/javascript-algorithms-and-data-structures/regular-expressions/specify-only-the-lower-number-of-matches/index.md) 。
[这种快速风格指南有助于确保您的拉取请求被接受](https://github.com/freecodecamp/guides/blob/master/README.md) 。

View File

@@ -0,0 +1,33 @@
---
title: Specify Upper and Lower Number of Matches
localeTitle: 指定上下匹配数
---
## 指定上下匹配数
记住`/a{2,4}/`返回`true` 只要有间两到四个A的一起。对于任何超过四个a的字符串它将返回`true`
所有这些字符串都将返回`true`
```javascript
let threeAs = "aaa";
let fourAs = "aaaa";
let sevenAs = "aaaaaaa";
let myRegex = /a{2,4}/;
myRegex.test(threeAs) ; // true
myRegex.test(fourAs) ; // true
myRegex.test(sevenAs) ; // true
```
## Spolier Alert
请记住在`Oh{3,6}`之后使用`\s`来包含空格,然后使用`no`来通过所有测试用例。所有测试用例都是使用大写字母O编写的但是也可以使用`ignore-case`传递测试用例: `/oh{3,6}\sno/i`
## 解:
```javascript
let ohStr = "Ohhh no";
let ohRegex = /Oh{3,6}\sno/; // Change this line
let result = ohRegex.test(ohStr);
```

View File

@@ -0,0 +1,23 @@
---
title: Use Capture Groups to Search and Replace
localeTitle: 使用捕获组进行搜索和替换
---
## 使用捕获组进行搜索和替换
使用带有第一个参数集的`.replace()`来查找要替换的原始字符串的一部分,第二个参数应该是替换。
## 提示1
修改正则表达式,以便`fixRegex`检测要替换的字符串部分,并将变量`replaceText`修改为将替换`fixRegex`的字符串。
## 剧透警报 - 提前解决!
## 解
```javascript
let huhText = "This sandwich is good.";
let fixRegex = /good/; // Change this line
let replaceText = "okey-dokey"; // Change this line
let result = huhText.replace(fixRegex, replaceText);
```

View File

@@ -0,0 +1,22 @@
---
title: Using the Test Method
localeTitle: 使用测试方法
---
## 使用测试方法
在这个挑战,你检查是否字符串包含一定的“正则表达式”,或**正则表达式** **REG** ular **前** pressions。您将使用`test()`方法来执行此操作。
## 提示1
`myRegex`上调用测试方法。您认为这个论点是什么?
## 剧透警报 - 提前解决!
## 解
```javascript
let myString = "Hello, World!";
let myRegex = /Hello/;
let result = myRegex.test(myString); // Change this line
```