diff options
author | t7yang <t7yang@gmail.com> | 2022-01-10 08:38:07 +0800 |
---|---|---|
committer | Irvin <irvinfly@gmail.com> | 2022-02-16 02:35:54 +0800 |
commit | c40612041809fe289aba58aefa170bbe784aba1f (patch) | |
tree | 8ca89b071d04afcf7abd6d9a04d0765a041d9c8a /files/zh-cn/web/javascript/guide | |
parent | 12a899ab8540bc84f56a0dc6491be80a48499d49 (diff) | |
download | translated-content-c40612041809fe289aba58aefa170bbe784aba1f.tar.gz translated-content-c40612041809fe289aba58aefa170bbe784aba1f.tar.bz2 translated-content-c40612041809fe289aba58aefa170bbe784aba1f.zip |
remove name attribute for zh-CN
Diffstat (limited to 'files/zh-cn/web/javascript/guide')
5 files changed, 61 insertions, 61 deletions
diff --git a/files/zh-cn/web/javascript/guide/control_flow_and_error_handling/index.html b/files/zh-cn/web/javascript/guide/control_flow_and_error_handling/index.html index 5d7b3f356e..4ec8d52e11 100644 --- a/files/zh-cn/web/javascript/guide/control_flow_and_error_handling/index.html +++ b/files/zh-cn/web/javascript/guide/control_flow_and_error_handling/index.html @@ -278,7 +278,7 @@ catch (e) { logMyErrors(e); // pass exception object to error handler -> your own function }</pre> -<h4 id="The_catch_Block" name="The_catch_Block"><code>catch</code> 块</h4> +<h4 id="The_catch_Block"><code>catch</code> 块</h4> <p>你可以使用<code>catch</code>块来处理所有可能在<code>try</code>块中产生的异常。</p> @@ -367,7 +367,7 @@ try { // caught inner "bogus" </pre> -<h4 id="Nesting_try...catch_Statements" name="Nesting_try...catch_Statements">嵌套 try...catch 语句</h4> +<h4 id="Nesting_try...catch_Statements">嵌套 try...catch 语句</h4> <p>你可以嵌套一个或多个<code>try ... catch</code>语句。如果一个内部<code>try ... catch</code>语句没有<code>catch</code>块,它需要有一个<code>finally</code>块,并且封闭的<code>try ... catch</code>语句的<code>catch</code>块被检查匹配。有关更多信息,请参阅<a href="/zh-CN/docs/Web/JavaScript/Reference/Statements/try...catch">try... catch</a>参考页上的<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch#Nested_try-blocks">嵌套try-blocks</a>。</p> diff --git a/files/zh-cn/web/javascript/guide/details_of_the_object_model/index.html b/files/zh-cn/web/javascript/guide/details_of_the_object_model/index.html index ba337d158f..7df37741c4 100644 --- a/files/zh-cn/web/javascript/guide/details_of_the_object_model/index.html +++ b/files/zh-cn/web/javascript/guide/details_of_the_object_model/index.html @@ -14,7 +14,7 @@ translation_of: Web/JavaScript/Guide/Details_of_the_Object_Model <p>本节假设您已经有一些 JavaScript 基础,并且用 JavaScript 函数创建过简单的对象。</p> -<h2 id="class-based_vs_prototype-based_languages" name="class-based_vs_prototype-based_languages">基于类 vs 基于原型的语言</h2> +<h2 id="class-based_vs_prototype-based_languages">基于类 vs 基于原型的语言</h2> <p>基于类的面向对象语言,比如 Java 和 C++,是构建在两个不同实体之上的:类和实例。</p> @@ -313,7 +313,7 @@ mark.projects = ["navigator"];</pre> <p><img alt="" class="internal" src="/@api/deki/files/4422/=figure8.4.png" style="height: 519px; width: 833px;"><br> <small><strong>添加属性</strong></small></p> -<h2 id="more_flexible_constructors" name="more_flexible_constructors">更灵活的构造器</h2> +<h2 id="more_flexible_constructors">更灵活的构造器</h2> <p>到目前为止,本文所展示的构造函数都不能让你在创建新实例时为其制定属性值。其实我们也可以像 Java 一样,为构造器提供参数以初始化实例的属性值。下图展示了一种实现方式。</p> diff --git a/files/zh-cn/web/javascript/guide/expressions_and_operators/index.html b/files/zh-cn/web/javascript/guide/expressions_and_operators/index.html index bced40f16d..cd87597de3 100644 --- a/files/zh-cn/web/javascript/guide/expressions_and_operators/index.html +++ b/files/zh-cn/web/javascript/guide/expressions_and_operators/index.html @@ -368,7 +368,7 @@ var var2 = 4;</pre> </tbody> </table> -<h4 id="Bitwise_Logical_Operators" name="Bitwise_Logical_Operators">位逻辑运算符</h4> +<h4 id="Bitwise_Logical_Operators">位逻辑运算符</h4> <p>概念上来讲, 位逻辑运算符工作流程如下:</p> @@ -430,7 +430,7 @@ After: 10100000000000000110000000000001</code></pre> <p>注意位运算符“非”将所有的32位取反,而值的最高位(最左边的一位)为1则表示负数(2-补码表示法)。</p> -<h4 id="Bitwise_Shift_Operators" name="Bitwise_Shift_Operators">移位运算符</h4> +<h4 id="Bitwise_Shift_Operators">移位运算符</h4> <p>移位运算符带两个操作数:第一个是待移位的数,第二个是指定第一个数要被移多少位的数。移位的方向由运算符来控制.</p> @@ -534,7 +534,7 @@ var n2 = !false; // !f returns true var n3 = !"Cat"; // !t returns false </pre> -<h4 id="Short-Circuit_Evaluation" name="Short-Circuit_Evaluation">短路求值</h4> +<h4 id="Short-Circuit_Evaluation">短路求值</h4> <p>作为逻辑表达式进行求值是从左到右,它们是为可能的“短路”的出现而使用以下规则进行测试:</p> @@ -560,7 +560,7 @@ var n3 = !"Cat"; // !t returns false <code>myString += "bet"; // 返回 "alphabet" </code> </pre> -<h3 id="conditional_operator" name="conditional_operator">条件(三元)运算符</h3> +<h3 id="conditional_operator">条件(三元)运算符</h3> <p><a href="/zh-CN/docs/Web/JavaScript/Reference/Operators/Conditional_Operator">条件运算符</a>是JavaScript中唯一需要三个操作数的运算符。运算的结果根据给定条件在两个值中取其一。语法为:</p> @@ -576,7 +576,7 @@ var n3 = !"Cat"; // !t returns false <p>当 <code>age</code> 大于等于18的时候,将“adult”赋值给<code> status</code>;否则将“minor”赋值给 <code>status</code>。</p> -<h3 id="comma_operator" name="comma_operator">逗号操作符</h3> +<h3 id="comma_operator">逗号操作符</h3> <p><a href="/zh-CN/docs/Web/JavaScript/Reference/Operators/Comma_Operator">逗号操作符</a>(<code>,</code>)对两个操作数进行求值并返回最终操作数的值。它常常用在 <code>for</code> 循环中,在每次循环时对多个变量进行更新。</p> @@ -588,11 +588,11 @@ var a = [x, x, x, x, x]; for (var i = 0, j = 9; i <= j; i++, j--) console.log('a[' + i + '][' + j + ']= ' + a[i][j]);</pre> -<h3 id="delete" name="delete">一元操作符</h3> +<h3 id="delete">一元操作符</h3> <p>一元操作符仅对应一个操作数。</p> -<h4 id="delete" name="delete"><code>delete</code></h4> +<h4 id="delete"><code>delete</code></h4> <p><code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/delete">delete</a></code>操作符,删除一个对象的属性或者一个数组中某一个键值。语法如下:</p> @@ -642,7 +642,7 @@ if (3 in trees) { } </pre> -<h4 id="typeof" name="typeof"><code>typeof</code></h4> +<h4 id="typeof"><code>typeof</code></h4> <p><a href="/zh-CN/docs/Web/JavaScript/Reference/Operators/typeof">typeof操作符</a> 可通过下面2种方式使用:</p> @@ -705,7 +705,7 @@ typeof Option; // returns "function" typeof String; // returns "function" </pre> -<h4 id="void" name="void"><code>void</code></h4> +<h4 id="void"><code>void</code></h4> <p>void 运算符运用方法如下:</p> @@ -730,7 +730,7 @@ Click here to submit</a></pre> <p>关系操作符对操作数进行比较,根据比较结果真或假,返回相应的布尔值。</p> -<h4 id="in" name="in"><code>in</code></h4> +<h4 id="in"><code>in</code></h4> <p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/in"><code>in</code>操作符</a>,如果所指定的<strong>属性</strong>确实存在于所指定的对象中,则会返回<code>true</code>,语法如下:</p> @@ -761,7 +761,7 @@ var mycar = {make: "Honda", model: "Accord", year: 1998}; "model" in mycar; // returns true </pre> -<h4 id="instanceof" name="instanceof"><code>instanceof</code></h4> +<h4 id="instanceof"><code>instanceof</code></h4> <p>如果所判别的对象确实是所指定的类型,则返回<code>true</code>。其语法如下:</p> @@ -885,9 +885,9 @@ if (theDay instanceof Date) { <li>左值表达式: 分配给左值。</li> </ul> -<h3 id="new" name="new">基本表达式</h3> +<h3 id="new">基本表达式</h3> -<h4 id="this" name="this"><code>this</code></h4> +<h4 id="this"><code>this</code></h4> <p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this"><code>this</code></a>关键字被用于指代当前的对象,通常,<code>this</code>指代的是方法中正在被调用的对象。用法如下:</p> @@ -952,7 +952,7 @@ var abc = [ "A", "B", "C" ]; <p>左值可以作为赋值的目标。</p> -<h4 id="new" name="new"><code>new</code></h4> +<h4 id="new"><code>new</code></h4> <p>你可以使用<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new"><code>new</code> operator</a> 创建一个自定义类型或者是<code>预置类型</code>的对象实例。用法如下:</p> diff --git a/files/zh-cn/web/javascript/guide/introduction/index.html b/files/zh-cn/web/javascript/guide/introduction/index.html index 3b8cfb9724..f6a85d1e2d 100644 --- a/files/zh-cn/web/javascript/guide/introduction/index.html +++ b/files/zh-cn/web/javascript/guide/introduction/index.html @@ -45,7 +45,7 @@ translation_of: Web/JavaScript/Guide/Introduction <p>这意味着,在浏览器中,JavaScript 可以改变网页(DOM)的外观与样式。同样地,在服务器上,Node.js 中的 JavaScript 可以对浏览器上编写的代码发出的客户端请求做出响应。</p> -<h2 id="JavaScript_and_Java" name="JavaScript_and_Java">JavaScript 和 Java</h2> +<h2 id="JavaScript_and_Java">JavaScript 和 Java</h2> <p>JavaScript 和 Java 有一些共性但是在另一些方面有着根本性区别。JavaScript语言类似 Java 但是并没有 Java 的静态类型和强类型检查特性。JavaScript 遵循了 Java 的表达式语法,命名规范以及基础流程控制,这也是 JavaScript 从 LiveScript 更名的原因。</p> @@ -83,13 +83,13 @@ translation_of: Web/JavaScript/Guide/Introduction <p>请查看章节 <a href="/zh-CN/docs/Web/JavaScript/Guide/Details_of_the_Object_Model">对象模型的详情</a> 来了解更多JavaScript和Java的不同。</p> -<h2 id="JavaScript_and_the_ECMAScript_Specification" name="JavaScript_and_the_ECMAScript_Specification">JavaScript 和 ECMAScript 规范</h2> +<h2 id="JavaScript_and_the_ECMAScript_Specification">JavaScript 和 ECMAScript 规范</h2> <p>JavaScript 的标准化组织是 <a class="external" href="http://www.ecma-international.org/">ECMA</a> ——这个欧洲信息与通信系统标准化协会提供基于 Javascript 的标准化方案(ECMA 原先是欧洲计算机制造商协会的首字母缩写)。这种标准化版本的 JavaScript 被称作 ECMAScript,在所有支持该标准的应用中以相同的方式工作。公司可以使用开放标准语言来开发他们自己的 JavaScript 实现版本。ECMAScript 标准在ECMA-262规范中进行文档化。 参照 <a href="/en-US/docs/Web/JavaScript/New_in_JavaScript">JavaScript的新特性</a> 以便学习更多关于不同版本的 JavaScript 和 ECMAScript 规范版本。</p> <p>ECMA-262 标准也通过了 国际标准化组织(<a class="external" href="http://www.iso.ch/">ISO</a>)的 ISO-16262。你可以<a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">在这里</a>找到该规范文件。 ECMAScript 规范并没有描述文档对象模型(<a href="/zh-CN/docs/Web/API/Document_Object_Model">DOM</a>),该模型由 万维网联盟(<a href="http://www.w3.org/">W3C</a>) 制定。DOM 定义了HTML文件对象被脚本操作的方法。为了更清楚地了解当使用JavaScript编程时用到的不同技术,请参阅 <a href="/zh-CN/docs/Web/JavaScript/JavaScript_technologies_overview">JavaScript 技术概述</a>。</p> -<h3 id="JavaScript_Documentation_versus_the_ECMAScript_Specification" name="JavaScript_Documentation_versus_the_ECMAScript_Specification">JavaScript 文献 和 ECMAScript 规范</h3> +<h3 id="JavaScript_Documentation_versus_the_ECMAScript_Specification">JavaScript 文献 和 ECMAScript 规范</h3> <p>ECMAScript规范是实现ECMAScript的一组需求;如果您想在ECMAScript实现或引擎(如Firefox中的SpiderMonkey或Chrome中的V8)中实现符合标准的语言特性,那么它是非常有用的。</p> diff --git a/files/zh-cn/web/javascript/guide/regular_expressions/index.html b/files/zh-cn/web/javascript/guide/regular_expressions/index.html index 5534db8860..945081c966 100644 --- a/files/zh-cn/web/javascript/guide/regular_expressions/index.html +++ b/files/zh-cn/web/javascript/guide/regular_expressions/index.html @@ -70,7 +70,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions </thead> <tbody> <tr> - <td><a href="#special-backslash" id="special-backslash" name="special-backslash"><code>\</code></a></td> + <td><a href="#special-backslash" id="special-backslash"><code>\</code></a></td> <td> <p>依照下列规则匹配:</p> @@ -82,7 +82,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions </td> </tr> <tr> - <td><a href="#special-caret" id="special-caret" name="special-caret"><code>^</code></a></td> + <td><a href="#special-caret" id="special-caret"><code>^</code></a></td> <td> <p>匹配输入的开始。如果多行标志被设置为 true,那么也匹配换行符后紧跟的位置。</p> @@ -92,7 +92,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions </td> </tr> <tr> - <td><a href="#special-dollar" id="special-dollar" name="special-dollar"><code>$</code></a></td> + <td><a href="#special-dollar" id="special-dollar"><code>$</code></a></td> <td> <p>匹配输入的结束。如果多行标志被设置为 true,那么也匹配换行符前的位置。</p> @@ -100,7 +100,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions </td> </tr> <tr> - <td><a href="#special-asterisk" id="special-asterisk" name="special-asterisk"><code>*</code></a></td> + <td><a href="#special-asterisk" id="special-asterisk"><code>*</code></a></td> <td> <p>匹配前一个表达式 0 次或多次。等价于 <code>{0,}</code>。</p> @@ -108,7 +108,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions </td> </tr> <tr> - <td><a href="#special-plus" id="special-plus" name="special-plus"><code>+</code></a></td> + <td><a href="#special-plus" id="special-plus"><code>+</code></a></td> <td> <p>匹配前面一个表达式 1 次或者多次。等价于 <code>{1,}</code>。</p> @@ -116,7 +116,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions </td> </tr> <tr> - <td><a href="#special-questionmark" id="special-questionmark" name="special-questionmark"><code>?</code></a></td> + <td><a href="#special-questionmark" id="special-questionmark"><code>?</code></a></td> <td> <p>匹配前面一个表达式 0 次或者 1 次。等价于 <code>{0,1}</code>。</p> @@ -128,7 +128,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions </td> </tr> <tr> - <td><a href="#special-dot" id="special-dot" name="special-dot"><code>.</code></a></td> + <td><a href="#special-dot" id="special-dot"><code>.</code></a></td> <td> <p>(小数点)默认匹配除换行符之外的任何单个字符。</p> @@ -138,7 +138,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions </td> </tr> <tr> - <td><a href="#special-capturing-parentheses" id="special-capturing-parentheses" name="special-capturing-parentheses"><code>(x)</code></a></td> + <td><a href="#special-capturing-parentheses" id="special-capturing-parentheses"><code>(x)</code></a></td> <td> <p>像下面的例子展示的那样,它会匹配 'x' 并且记住匹配项。其中括号被称为<em>捕获括号</em>。</p> @@ -146,13 +146,13 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions </td> </tr> <tr> - <td><a href="#special-non-capturing-parentheses" id="special-non-capturing-parentheses" name="special-non-capturing-parentheses"><code>(?:x)</code></a></td> + <td><a href="#special-non-capturing-parentheses" id="special-non-capturing-parentheses"><code>(?:x)</code></a></td> <td> <p>匹配 'x' 但是不记住匹配项。这种括号叫作<em>非捕获括号</em>,使得你能够定义与正则表达式运算符一起使用的子表达式。看看这个例子 <code>/(?:foo){1,2}/</code>。如果表达式是 <code>/foo{1,2}/</code>,<code>{1,2}</code> 将只应用于 'foo' 的最后一个字符 'o'。如果使用非捕获括号,则 <code>{1,2}</code> 会应用于整个 'foo' 单词。更多信息,可以参阅下文的 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Using_parentheses">Using parentheses</a> 条目.</p> </td> </tr> <tr> - <td><a href="#special-lookahead" id="special-lookahead" name="special-lookahead"><code>x(?=y)</code></a></td> + <td><a href="#special-lookahead" id="special-lookahead"><code>x(?=y)</code></a></td> <td> <p>匹配'x'仅仅当'x'后面跟着'y'.这种叫做先行断言。</p> @@ -160,7 +160,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions </td> </tr> <tr> - <td><a href="#special-lookahead" id="special-lookahead" name="special-lookahead"><code>(?<=y)</code></a>x</td> + <td><a href="#special-lookahead" id="special-lookahead"><code>(?<=y)</code></a>x</td> <td> <p>匹配'x'仅当'x'前面是'y'.这种叫做后行断言。</p> @@ -168,7 +168,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions </td> </tr> <tr> - <td><a href="#special-negated-look-ahead" id="special-negated-look-ahead" name="special-negated-look-ahead"><code>x(?!y)</code></a></td> + <td><a href="#special-negated-look-ahead" id="special-negated-look-ahead"><code>x(?!y)</code></a></td> <td> <p>仅仅当'x'后面不跟着'y'时匹配'x',这被称为正向否定查找。</p> @@ -186,7 +186,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions </td> </tr> <tr> - <td><a href="#special-or" id="special-or" name="special-or"><code>x|y</code></a></td> + <td><a href="#special-or" id="special-or"><code>x|y</code></a></td> <td> <p>匹配‘x’或者‘y’。</p> @@ -194,12 +194,12 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions </td> </tr> <tr> - <td><a href="#special-quantifier" id="special-quantifier" name="special-quantifier"><code>{n}</code></a></td> + <td><a href="#special-quantifier" id="special-quantifier"><code>{n}</code></a></td> <td>n 是一个正整数,匹配了前面一个字符刚好出现了 n 次。<br> 比如, /a{2}/ 不会匹配“candy”中的'a',但是会匹配“caandy”中所有的 a,以及“caaandy”中的前两个'a'。</td> </tr> <tr> - <td><a href="#special-quantifier" id="special-quantifier" name="special-quantifier"><code>{n,}</code></a></td> + <td><a href="#special-quantifier" id="special-quantifier"><code>{n,}</code></a></td> <td> <p>n是一个正整数,匹配前一个字符至少出现了n次。</p> @@ -207,7 +207,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions </td> </tr> <tr> - <td><a href="#special-quantifier-range" id="special-quantifier-range" name="special-quantifier-range"><code>{n,m}</code></a></td> + <td><a href="#special-quantifier-range" id="special-quantifier-range"><code>{n,m}</code></a></td> <td> <p>n 和 m 都是整数。匹配前面的字符至少n次,最多m次。如果 n 或者 m 的值是0, 这个值被忽略。</p> @@ -215,12 +215,12 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions </td> </tr> <tr> - <td><a href="#special-character-set" id="special-character-set" name="special-character-set"><code>[xyz]</code></a></td> + <td><a href="#special-character-set" id="special-character-set"><code>[xyz]</code></a></td> <td>一个字符集合。匹配方括号中的任意字符,包括<a href="/zh-CN/docs/Web/JavaScript/Guide/Grammar_and_types">转义序列</a>。你可以使用破折号(-)来指定一个字符范围。对于点(.)和星号(*)这样的特殊符号在一个字符集中没有特殊的意义。他们不必进行转义,不过转义也是起作用的。<br> 例如,[abcd] 和[a-d]是一样的。他们都匹配"brisket"中的‘b’,也都匹配“city”中的‘c’。/[a-z.]+/ 和/[\w.]+/与字符串“test.i.ng”匹配。</td> </tr> <tr> - <td><a href="#special-negated-character-set" id="special-negated-character-set" name="special-negated-character-set"><code>[^xyz]</code></a></td> + <td><a href="#special-negated-character-set" id="special-negated-character-set"><code>[^xyz]</code></a></td> <td> <p>一个反向字符集。也就是说, 它匹配任何没有包含在方括号中的字符。你可以使用破折号(-)来指定一个字符范围。任何普通字符在这里都是起作用的。</p> @@ -228,13 +228,13 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions </td> </tr> <tr> - <td><a href="#special-backspace" id="special-backspace" name="special-backspace"><code>[\b]</code></a></td> + <td><a href="#special-backspace" id="special-backspace"><code>[\b]</code></a></td> <td> <p>匹配一个退格(U+0008)。(不要和\b混淆了。)</p> </td> </tr> <tr> - <td><a href="#special-word-boundary" id="special-word-boundary" name="special-word-boundary"><code>\b</code></a></td> + <td><a href="#special-word-boundary" id="special-word-boundary"><code>\b</code></a></td> <td> <p>匹配一个词的边界。一个词的边界就是一个词不被另外一个“字”字符跟随的位置或者前面跟其他“字”字符的位置,例如在字母和空格之间。注意,匹配中不包括匹配的字边界。换句话说,一个匹配的词的边界的内容的长度是0。(不要和[\b]混淆了)</p> @@ -245,12 +245,12 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions /\w\b\w/将不能匹配任何字符串,因为在一个单词中间的字符永远也不可能同时满足没有“字”字符跟随和有“字”字符跟随两种情况。</p> <div class="note"> - <p><strong>注意:</strong> JavaScript的正则表达式引擎将<a href="http://www.ecma-international.org/ecma-262/5.1/#sec-15.10.2.6">特定的字符集</a>定义为“字”字符。不在该集合中的任何字符都被认为是一个断词。这组字符相当有限:它只包括大写和小写的罗马字母,十进制数字和下划线字符。不幸的是,重要的字符,例如“<a name="none"></a>é”或“ü”,被视为断词。</p> + <p><strong>注意:</strong> JavaScript的正则表达式引擎将<a href="http://www.ecma-international.org/ecma-262/5.1/#sec-15.10.2.6">特定的字符集</a>定义为“字”字符。不在该集合中的任何字符都被认为是一个断词。这组字符相当有限:它只包括大写和小写的罗马字母,十进制数字和下划线字符。不幸的是,重要的字符,例如“<a></a>é”或“ü”,被视为断词。</p> </div> </td> </tr> <tr> - <td><a href="#special-non-word-boundary" id="special-non-word-boundary" name="special-non-word-boundary"><code>\B</code></a></td> + <td><a href="#special-non-word-boundary" id="special-non-word-boundary"><code>\B</code></a></td> <td> <p>匹配一个非单词边界。匹配如下几种情况:</p> @@ -266,7 +266,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions </td> </tr> <tr> - <td><a href="#special-control" id="special-control" name="special-control"><code>\c<em>X</em></code></a></td> + <td><a href="#special-control" id="special-control"><code>\c<em>X</em></code></a></td> <td> <p>当X是处于A到Z之间的字符的时候,匹配字符串中的一个控制符。</p> @@ -274,7 +274,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions </td> </tr> <tr> - <td><a href="#special-digit" id="special-digit" name="special-digit"><code>\d</code></a></td> + <td><a href="#special-digit" id="special-digit"><code>\d</code></a></td> <td> <p>匹配一个数字<code>。</code><code>等价于[0-9]</code>。</p> @@ -282,7 +282,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions </td> </tr> <tr> - <td><a href="#special-non-digit" id="special-non-digit" name="special-non-digit"><code>\D</code></a></td> + <td><a href="#special-non-digit" id="special-non-digit"><code>\D</code></a></td> <td> <p>匹配一个非数字字符<code>。</code><code>等价于[^0-9]</code>。</p> @@ -290,19 +290,19 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions </td> </tr> <tr> - <td><a href="#special-form-feed" id="special-form-feed" name="special-form-feed"><code>\f</code></a></td> + <td><a href="#special-form-feed" id="special-form-feed"><code>\f</code></a></td> <td>匹配一个换页符 (U+000C)。</td> </tr> <tr> - <td><a href="#special-line-feed" id="special-line-feed" name="special-line-feed"><code>\n</code></a></td> + <td><a href="#special-line-feed" id="special-line-feed"><code>\n</code></a></td> <td>匹配一个换行符 (U+000A)。</td> </tr> <tr> - <td><a href="#special-carriage-return" id="special-carriage-return" name="special-carriage-return"><code>\r</code></a></td> + <td><a href="#special-carriage-return" id="special-carriage-return"><code>\r</code></a></td> <td>匹配一个回车符 (U+000D)。</td> </tr> <tr> - <td><a href="#special-white-space" id="special-white-space" name="special-white-space"><code>\s</code></a></td> + <td><a href="#special-white-space" id="special-white-space"><code>\s</code></a></td> <td> <p>匹配一个空白字符,包括空格、制表符、换页符和换行符。等价于[ \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]。</p> @@ -312,7 +312,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions </td> </tr> <tr> - <td><a href="#special-non-white-space" id="special-non-white-space" name="special-non-white-space"><code>\S</code></a></td> + <td><a href="#special-non-white-space" id="special-non-white-space"><code>\S</code></a></td> <td> <p>匹配一个非空白字符。等价于 <code>[^ </code>\f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff<code>]</code>。</p> @@ -320,15 +320,15 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions </td> </tr> <tr> - <td><a href="#special-tab" id="special-tab" name="special-tab"><code>\t</code></a></td> + <td><a href="#special-tab" id="special-tab"><code>\t</code></a></td> <td>匹配一个水平制表符 (U+0009)。</td> </tr> <tr> - <td><a href="#special-vertical-tab" id="special-vertical-tab" name="special-vertical-tab"><code>\v</code></a></td> + <td><a href="#special-vertical-tab" id="special-vertical-tab"><code>\v</code></a></td> <td>匹配一个垂直制表符 (U+000B)。</td> </tr> <tr> - <td><a href="#special-word" id="special-word" name="special-word"><code>\w</code></a></td> + <td><a href="#special-word" id="special-word"><code>\w</code></a></td> <td> <p>匹配一个单字字符(字母、数字或者下划线)。等价于 <code>[A-Za-z0-9_]</code>。</p> @@ -336,7 +336,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions </td> </tr> <tr> - <td><a href="#special-non-word" id="special-non-word" name="special-non-word"><code>\W</code></a></td> + <td><a href="#special-non-word" id="special-non-word"><code>\W</code></a></td> <td> <p>匹配一个非单字字符。等价于 <code>[^A-Za-z0-9_]</code>。</p> @@ -344,7 +344,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions </td> </tr> <tr> - <td><a href="#special-backreference" id="special-backreference" name="special-backreference"><code>\<em>n</em></code></a></td> + <td><a href="#special-backreference" id="special-backreference"><code>\<em>n</em></code></a></td> <td> <p>在正则表达式中,它返回最后的第n个子捕获匹配的子字符串(捕获的数目以左括号计数)。</p> @@ -352,20 +352,20 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions </td> </tr> <tr> - <td><a href="#special-null" id="special-null" name="special-null"><code>\0</code></a></td> + <td><a href="#special-null" id="special-null"><code>\0</code></a></td> <td>匹配 NULL(U+0000)字符, 不要在这后面跟其它小数,因为 <code>\0<digits></code> 是一个八进制转义序列。</td> </tr> <tr> - <td><a href="#special-hex-escape" id="special-hex-escape" name="special-hex-escape"><code>\xhh</code></a></td> + <td><a href="#special-hex-escape" id="special-hex-escape"><code>\xhh</code></a></td> <td>匹配一个两位十六进制数(\x00-\xFF)表示的字符。</td> </tr> <tr> - <td><a href="#special-unicode-escape" id="special-unicode-escape" name="special-unicode-escape"><code>\uhhhh</code></a></td> + <td><a href="#special-unicode-escape" id="special-unicode-escape"><code>\uhhhh</code></a></td> <td>匹配一个四位十六进制数表示的 UTF-16 代码单元。</td> </tr> <tr> <td> - <p><code><a href="#special-unicode-escape-es6" id="special-unicode-escape-es6" name="special-unicode-escape-es6">\u{hhhh}</a>或\u{hhhhh}</code></p> + <p><code><a href="#special-unicode-escape-es6" id="special-unicode-escape-es6">\u{hhhh}</a>或\u{hhhhh}</code></p> </td> <td>(仅当设置了u标志时)匹配一个十六进制数表示的 Unicode 字符。</td> </tr> @@ -543,7 +543,7 @@ console.log("The value of lastIndex is " + /d(b+)d/g.lastIndex); <p>当发生/d(b+)d/g使用两个不同状态的正则表达式对象,lastIndex属性会得到不同的值。如果你需要访问一个正则表达式的属性,则需要创建一个对象初始化生成器,你应该首先把它赋值给一个变量。</p> -<h3 id="使用括号的子字符串匹配_2"><a name="使用括号的子字符串匹配">使用括号的子字符串匹配</a></h3> +<h3 id="使用括号的子字符串匹配_2"><a>使用括号的子字符串匹配</a></h3> <p>一个正则表达式模式使用括号,将导致相应的子匹配被记住。例如,/a(b)c /可以匹配字符串“abc”,并且记得“b”。回调这些括号中匹配的子串,使用数组元素[1],……[n]。</p> |