示例
下面的示例创建一个包含正则表达式模式及相关标志的对象(re),向您演示正则表达式对象的用法。在本例中,作为结果的正则表达式对象又用于 match 方法中:
function MatchDemo(){
var r, re; // 声明变量。
var s = "The rain in Spain falls mainly in the plain";
re = new RegExp("Spain","i"); // 创建正则表达式对象。
r = s.match(re); // 在字符串 s 中查找匹配。
return(r); // 返回匹配结果。
}
有regex这个函数吗?
翻了一下msdn找到这个
[JScript]
public class Regex implements ISerializable
Remarks
The Regex class contains several static methods that allow you to use a regular expression without explicitly creating a Regex object. Using a static method is equivalent to constructing a Regex object, using it once and then destroying it.