C#: Get a random string

Background: Sometimes, we need to generate some random strings for testing purpose. When I met this situation, I was surprised that C# has no such built-in methods inside its Random Class. So I had t... [More]

给JavaScript的String对象添加startsWith(), endsWith()等方法

用C#用习惯了,在写JavaScript代码时,用字符串时没有了startsWith()和endsWith()方法颇感不适应。于是自己给JavaScript的String对象添加两个,顺便再添加一个删除所有空白字符的方法。 // // 给字符串对象添加一个startsWith()方法 // String.prototype.startsWith = f... [More]

给JavaScript的String对象添加一个trim()方法

一、问题 在对字符串的处理中,去掉有效字符两边的空白字符是一个经常性的需求。于是很多语言中都有专门做这件事的字符串处理函数trim(),如在VB中,你可以使用 Trim(“      叽歪      ") 得到 “叽歪"。 在 JavaScript 中,String ... [More]