blob: 80f4972ca0387672b93b420cdc8e82def04d426b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
---
title: RegExp.prototype.toSource()
slug: Web/JavaScript/Reference/Global_Objects/RegExp/toSource
tags:
- JavaScript
- Method
- Non-standard
- Prototype
- RegExp
translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/toSource
---
<p>{{JSRef("Global_Objects", "RegExp")}}{{ Non-standard_header() }}</p>
<h2 id="Summary" name="Summary">概述</h2>
<p>返回一个字符串,代表当前对象的源代码</p>
<h2 id="Syntax" name="Syntax">语法</h2>
<pre class="syntaxbox"><code><var>regexObj</var>.toSource()
</code></pre>
<h2 id="Description" name="Description">描述</h2>
<p><code>toSource</code>方法返回值如下:</p>
<ul>
<li>对于内置的<code>RegExp</code>对象, <code>toSource</code> 如下字符串:</li>
</ul>
<pre class="brush: js">function RegExp() {
[native code]
}
</pre>
<ul>
<li>对于一个<code>RegExp实例</code>, <code>toSource返回代表该正则的字符串.</code></li>
</ul>
<p>该方法通常由JavaScript内部隐含调用,而不会明确的出现在用户代码中.</p>
<h2 id="See_Also" name="See_Also">相关链接</h2>
<p><a href="/zh-cn/JavaScript/Reference/Global_Objects/Object/toSource" title="zh-cn/JavaScript/Reference/Global_Objects/Object/toSource">Object.prototype.toSource</a></p>
|