I’ve tried to port Query Parser written in JScript from Integrating User Search with ASP and Microsoft SQL Server Full-text Search to C#. The “Converting JScript.NET to C#” tool is quite useful, but doesn’t do all the job. I wanted to understand RegExp properties , but MSDN JScript help example doesn’t show output. So I’ve wrote simple exampleRun.js using WScript.Echo:
WScript.Echo (matchDemo());
function matchDemo(){
var s;
var re = new RegExp("d(b+)(d)","ig");
var str = "cdbBdbsbdbdz";
var arr = re.exec(str);
s = "$1 contains: " + RegExp.$1 + "\n";
s += "$2 contains: " + RegExp.$2 + "\n";
s += "$3 contains: " + RegExp.$3 + "\n";
s += "input returns : " + RegExp.input + "\n";
s += "lastMatch returns: " + RegExp.lastMatch + "\n";
s += "leftContext returns: " + RegExp.leftContext + "\n";
s += "rightContext returns: " + RegExp.rightContext + "\n";
s += "lastParen returns: " + RegExp.lastParen + "\n";
return(s);
}
Which produces the following output
$1 contains: bB
$2 contains: d
$3 contains:
input returns : cdbBdbsbdbdz
lastMatch returns: dbBd
leftContext returns: c
rightContext returns: bsbdbdz
lastParen returns: d
Update: I’ve noticed,that MSDN Jscript.NET help includes the output, which is quite nice.
posted @ Wednesday, June 21, 2006 7:53 AM