$1...$9 属性 (RegExp) (JavaScript)
来源:互联网 发布:网络高清摄像机演示 编辑:程序博客网 时间:2024/06/03 21:20
$1...$9 属性 (RegExp) (JavaScript)
返回在模式匹配期间找到的,所存储的最近的九个部分。 只读。
RegExp.$n
参数
备注每当产生一个带括号的成功匹配时,$1...$9 属性的值就被修改。 可以在一个正则表达式模式中指定任意多个带括号的子匹配,但只能存储最新的九个。
示例下面的示例执行正则表达式搜索。 它显示了全局 RegExp 对象中的匹配项和子匹配项。 子匹配项是 $1…$9 属性中包含的成功的带括号匹配项。 该示例还显示了由 exec 方法返回的数组中的匹配项和子匹配项。
JavaScriptvar newLine = "<br />";var re = /(\w+)@(\w+)\.(\w+)/gvar src = "Please send mail to george@contoso.com and someone@example.com. Thanks!"var result;var s = "";// Get the first match.result = re.exec(src);while (result != null) { // Show the entire match. s += newLine; // Show the match and submatches from the RegExp global object. s += "RegExp.lastMatch: " + RegExp.lastMatch + newLine; s += "RegExp.$1: " + RegExp.$1 + newLine; s += "RegExp.$2: " + RegExp.$2 + newLine; s += "RegExp.$3: " + RegExp.$3 + newLine; // Show the match and submatches from the array that is returned // by the exec method. for (var index = 0; index < result.length; index++) { s += index + ": "; s += result[index]; s += newLine; } // Get the next match. result = re.exec(src);}document.write(s);// Output:// RegExp.lastMatch: george@contoso.com// RegExp.$1: george// RegExp.$2: contoso// RegExp.$3: com// 0: george@contoso.com// 1: george// 2: contoso// 3: com// RegExp.lastMatch: someone@example.com// RegExp.$1: someone// RegExp.$2: example// RegExp.$3: com// 0: someone@example.com// 1: someone// 2: example// 3: com
0 0
- $1...$9 属性 (RegExp) (JavaScript)
- JavaScript RegExp.$1...$9 属性详解
- JavaScript RegExp.$1...$9 属性详解
- javascript正则表达式RegExp的静态属性之$1-$9
- JavaScript 1.10 RegExp的方法和属性
- js正则对象RegExp的$1...$9 属性
- Javascript --RegExp
- JavaScript RegExp
- JavaScript RegExp
- javascript RegExp对象属性与方法和应用
- javascript 高级程序设计(一) 正则表达 RegExp实例属性
- RegExp.$1--RegExp.$9
- RegExp对象的属性
- JavaScript RegExp 对象参考
- JavaScript RegExp 对象
- JavaScript RegExp 对象
- JavaScript replace new RegExp
- JavaScript的RegExp对象
- vs2010 CString转换char *
- 网络拓扑图例库
- android 自定义viewR.styleable找不到或者是报错!
- 【转】常见数字IC设计、FPGA工程师面试题
- 分布式系统 缓存穿透与失效时的雪崩效应
- $1...$9 属性 (RegExp) (JavaScript)
- Lua代码编写规范
- [笔记]numpy中的tile与kron的用法
- 学习python基础语法中遇到的一些问题
- 黑马程序员——JAVA基础------集合框架(三)----Iterator
- crossApp初级-类的结构-2
- Java 堆内存模型
- 机器学习课程 Multivariate Linear Regression(多变量线性回归)
- 计算机视觉、机器学习相关领域论文和源代码大集合(非常实用)