Last week I took on a project to create a database application with searching capabilities and decided that (Microsoft’s) JScript would be my language of choice.
For some people maybe this would seem like a bad idea considering the fact that JScript/JavaScript is an uncompiled language and therefore may greatly lack the speed of a compiled language such as C++. The reason I chose JScript is because of how easy and flexible the language is, the fact that it has native abilities for reading XML files and the priviledged access to the FileSystem and Shell ActiveX controls (all coming together with the use of HTML Applications).
I ended up finishing the main searching algorithm which supports “regular expressions” and upon testing that algorithm on its’ calling algorithm with set arrays I found that I was able to get over 1-Million comparisons done per second on a 3.6 GHz processor. I have even improved upon the algorithm since by using the RegExp test() function supported in JScript (not supported in any browser but IE as far as I know). Here is the original code for anyone that may have any use for it. Any improvements on this code would also be greatly appreciated.
[CODE]function doContain(xinput,checkarr,regexmod,anyall,exact)
{
// xinput – Array of strings to search within
// checkarr – Array of strings to search for
// regexmod – Regular Expression search modifier(s) [case sensitivity “i”, etc.]
// anyall – Any: True; All: False;
// * Any – Return true if even one occurance is found
// * All – Return true only if all occurances are found
// exact – Only return true upon exact matches
var mpass = 0;
for(cxi=0;cxi<checkarr.length;cxi++)
{
var chkpass = false;
for(cxn=0;cxn<xinput.length;cxn++)
{
if(exact && xinput[cxn].length == checkarr[cxi].length && xinput[cxn].match(new RegExp(checkarr[cxi],regexmod))) chkpass = true;
else if(!exact && xinput[cxn].match(new RegExp(checkarr[cxi],regexmod))) chkpass = true;
if(chkpass) break;
}
if(chkpass) mpass++;
if(!anyall && mpass > 0) break;
}
if(!anyall && mpass > 0) return true;
else if(anyall && mpass == checkarr.length) return true;
else return false;
}