基于正则表达式匹配的CSS语法高亮及代码格式化
©2011 Copyright Ider Zheng
此项目中用到的Javascript偏门知识
prototype扩展已有的Javascript对象:
String.prototype.trim = function(){return this.replace(/^\s+|\s+$/g, "");}
Getter只读属性器:
    get EndlineMatcher()
        {
            return /\n|\r|\r\n/g;
        },
String.replace方法接受函数作为参数:
function HtmlEncode(original)
{
    var result = 
        original.replace(/\n|\r|\r\n| {2,}/g
                , function ($0)
                    {
                        if($0[0] == " ") return TextFormat.Space($0.length);
                        
                        return "<br />" + $0;
                    }
                );
    return result;
}
使用数组进行字符串重复:
    Space: function(num)
        {
            var times = parseInt(num);
            times = (times == NaN? 1:times+1); // times+1 length array has times intervals
            
            return new Array(times).join(" ");
        }
推荐.NET配套的通用数据层ORM框架:CYQ.Data 通用数据层框架