2006年08月
一、字符串格式
前导0的输出:
int x=5;
string str=x.ToString("D8");
//str="00000005"
二、字符串函数
取子字符串:
string str="123456789";
str=str.Substring(1,2);
//str="23"
查找子字符串的位置:
string str="123456789";
int index=str.IndexOf("3",0,str.Length);
//index=2
三、指定进制字符串转换为数字
string str="FF";
int i=Convert.ToInt32(str,16);
//i=255
string str="00000011";
int i=Convert.ToInt32(str,2);
//i=3
阅读全文>
发表于 @ 2006年08月29日 15:52:00|评论(loading...)|编辑
当前日期时间的获取:
DateTime datetime1=DateTime.Now;
日期时间的运算:
string str1=(datetime1.AddYears(1)).ToString();//加年份
string str1=(datetime1.AddMonths(1)).ToString();//加月份
string str1=(datetime1.AddDays(1)).ToString();//加日期
string str1=(datetime1.AddHours(1)).ToString();//加小时
string str1=(datetime1.AddMinutes(1)).ToString();//加分
string str1=(datetime1.AddSeconds(1)).ToString();//加秒
string str1=(datetime1.AddMilliseconds(1)).ToString();//加毫秒
string str1=(datetime1.AddYe阅读全文>
发表于 @ 2006年08月29日 15:50:00|评论(loading...)|编辑
常用的正则表达式及符号诠释
在脚本程序的写作中,正则表达式是经常用到的,但是正则表达式书写困难,可读性很差也是大家所知道的,今天写email的正则表达式时,由于经常写不对,后来决定gg一下,看看网上有没有现成的,结果发现网上已经提供了很多的常用的正则表达式了,不需要自己写的,而且应该是验证过的吧。
匹配中文字符的正则表达式: [\u4e00-\u9fa5]
匹配双字节字符(包括汉字在内):[^\x00-\xff]
匹配空行的正则表达式:\n[\s| ]*\r
匹配HTML标记的正则表达式:/.*|/
匹配首尾空格的正则表达式:(^\s*)|(\s*$)
匹配Email地址的正则表达式:\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
匹配网址URL的正则表达式:^[a-zA-z]+://(\\w+(-\\w+)*)(\\.(\\w+(-\\w+)*))*(\\?\\S*)?$
匹配帐号是否合法(字母开头,允许5-16字节,允许字母数字下划线):^[a-zA-Z][a-zA-Z0-9_]{4,15}$
匹配国内电话号码:(\d阅读全文>
发表于 @ 2006年08月29日 15:49:00|评论(loading...)|编辑
1. Just do it. 跟着感觉走。(耐克运动鞋)
2. Ask for more. 渴望无限。(百事流行鞋)
3. Obey your thirst. 服从你的渴望。(雪碧)
4. Feel the new space. 感受新境界。(三星电子)
5. Focus on life. 瞄准生活。(奥林巴斯相机)
6. Good to the last drop. 滴滴香浓,意犹未尽。(麦氏咖啡)
7. A Kodak moment. 就在柯达一刻。(柯达胶卷)/Share moments. Share life. (柯达胶卷)
8. Started Ahead. 成功之路,从头开始。(飘柔洗发水)
9. Make yourself heard. 理解就是沟通。(爱立信手机)
10. Intelligence everywhere. 智慧演绎,无处不在。(摩托罗拉手机)
11. The choice of a new generation. 新一代的选择。(百事可乐)
12. We integrate, you communicate阅读全文>
发表于 @ 2006年08月04日 09:54:00|评论(loading...)|编辑