Archive for July, 2008

Regular expressions

Wednesday, July 9th, 2008

Exclude some file types from a list
================================

function Filter()
    {
        var arr = new Array(9);
//Dummy
        arr[0] = "something.aspx";
        arr[1] = "something.ascx";
        arr[2] = "something.gif";
        arr[3] = "something.asrx";
        arr[4] = "something.jp";
        arr[5] = "something.cab";
        arr[6] = "something.bat";
        arr[7] = "something.arr";
        arr[8] = "something.ashx";
        var rgex = /.*[.](?!(aspx|ascx|gif)$).*$/;
        var filtered = new Array(8);

        for(var i=0;i<arr.length;i++)
        {
            if(rgex.test(arr[i]))
                filtered[i] = arr[i];
            else
                filtered[i] = "ok";

        }

    }