Wednesday, November 17, 2010
Saturday, September 18, 2010
游行的意义 *韩寒?*
首先,我认为在现代中国社会中,分为三个阶级,那就是主子,奴才和狗,而我们往往一人饰两角,至于饰演哪两个角色,我想不会有人觉得他在演主子吧。前一阵子,主子需要奴才去附和和伺候,但是现如今,主子需要狗去吼两声,因为在狗的逻辑里,无论主子怎么对待它,只要有外人来犯,狗总是该看家护院的。
当弄明白了这个以后,回头想想就容易多了。但是,在这三个阶级以内,好在我还有选择做花花草草的权力。我的选择依据是,对于相关部门,小事和大事他们的区别就是抗议一次和抗议十一次,有特权有能力的地方尚未出力,除了把人家日本大使变成了应召男郎以外,我们相关部门情绪稳定,并不见什么实际决心,别说武力上,连经济上都不敢有所动作。他们韬光养晦,所以我也韬光养晦。毕竟,我等做狗也罢,但要做一条戏狗,情以何堪。
纵观事态发展,领导的内心似乎并不愤怒,领导只是觉得窝囊,那自然,我们也只能跟着觉得窝囊,你哪有上街去表达窝囊的,那岂不是更窝囊。领导没面子的时候,我们给他们长脸,但领导有面子的时候,我们被他们掌嘴。我被欺负,我不能游,你被欺负,你让我游,我又情以何堪。你也别说这种民族国土大事应该是我们一起被欺负了,就算政府不作为,你活的一塌糊涂,也应该挺身而出。我自然可以挺身而出,但我的第一主题就是要求政府去作为,第二主题才是控诉来犯者,因为领土问题从来都不是老百姓能解决的和该去解决的,尤其是在我国,老百姓自己都没有一寸土地,,所有的一切,都是问政府租的,所以,理论上,这事对我来说,就是我的房东在和别人就一块在地上的瓦而争执,这块瓦的确是风大的时候从房东的房顶上掉下来的,但房东也不敢去捡,因为可能要和隔壁人家打架。那我等租客在里面搅和什么呢。无土地者要去为他人争取土地,无尊严者要去为他人捍卫尊严,这样的人多少钱一斤?一斤多少个?
但毕竟,这样的游行安全,好玩,显得很酷,关键是游完以后还能正常工作学习,甚至还有助于未来发展,毕竟也算不容易,所以大学生和老百姓抱着尝鲜唱黑脸的角度去游一游无妨。到时候政府唱一个白脸,说不定能有所见效。况且现在去游行玩的人相比起以前游行玩的人也有着些许不同,以前是彻底的国政不分,被卖数钱,现如今很多青年终于能够将所谓爱国这件事情想的更明白,他们虽然依然愤怒,但开始反思自己为何每次都是那么窝囊和被动,回头也能更客观的看待国家和政府的关系,这也算是一个进步。对于任何国家来说,国家就是一个女人,执政者就是占有她的男人,有幸福美满的,有相处和睦的,有家庭暴力的,有关系紧张的,有离婚再嫁的,有不能改嫁的,但无论如何,你爱一个女人总不能连她的男人也一起爱了去。
最后,这些都不重要,最重要的是,我,如果今天能为唐福珍谢朝平而游行,那么明天我就一定会为钓鱼岛和奥运火炬而游行。但这又是一个悖论,往往你能够为唐福珍谢朝平游行的时候,你往往就不会有钓鱼岛奥运火炬之类的事,而且更不会有唐福珍谢朝平之类的事出现。一个对内不能和平游行的民族,他的对外任何游行是完全没有价值的,那只是一场集体舞。
Thursday, July 29, 2010
世纪大骗局之1998香港金融保卫战
在日本陷入失落的十年长期衰退中,东南亚各国的经济发展取得了令人瞩目的成就,先后产生了韩国、台湾、香港、新加坡等亚洲四小龙,以及泰国、菲律宾、印度尼西亚和马来西亚等亚洲四小虎,这些国家在经济高速发展过程也积累了比较多的问题,这些国家大都实行固定汇率制或有管理的浮动汇率制,为快速发展大都积累了比较多的外债,经常账户长期巨额赤字,资本市场泡沫比较严重,具备被攻击的内在条件。从外部因素来说,1994年为提高出口竞争力,人民币一次性贬值 50%,显著提高了中国在亚洲的竞争力,对四小龙四小虎构成了比较大的压力,另一个更重要的外部因素,美国在90年代初推行的强势美元政策,对这些国家的资本外流创造了条件。
以美国索罗斯为首的对冲基金早就对肥得流油的东南亚小龙小虎们馋蜒欲滴,视为盘中餐,早在1994年就曾进行过试探性攻击,后因感到时机不成熟而放弃。1997年时机到来,自然不会放过,首先拿实力相对弱小的四小虎开刀,1997年2月索罗斯等大量沽空泰铢现货,同时买进远期泰铢合约,进行远期外汇掉期交易,泰铢贬值部分即是其盈利,泰国稍加抵抗就败下阵来,6月泰国财政部长在政治压力下辞职,惊慌失措的国内公司买入美元对冲其外汇风险敞口,外汇平准基金的干预导致外汇储备损失惨重,国内居民信心危机没有缓解,已超出了银行的控制范围,1997年7月泰国被迫放弃固定汇率制,汇率开始自由浮动,在此后的6个月里,泰铢兑美元的比价由26降到55。而且亚洲危机出现向其它国家扩散的迹象。
以索罗斯为首的对冲基金等国际金融机构又迅速的横扫东南亚,用同样的手法先后打败了马来西亚、菲律宾和印尼这些所谓的亚洲四小虎,接下来亚洲四小龙岌岌可危。
为了便于理解,在这里先对汇率制度做个简单解释,汇率制度分为浮动汇率制、受管理的浮动汇率制、固定汇率制、和联系汇率制,从金融危机尤其是货币危机的历史看,发生货币危机的国家一般是固定汇率制或实行受管理的浮动汇率制,限于篇幅这里就不深入解释其原因了。联系汇率制也称货币局制度,是固定汇率制的极端情况,货币局制度在一个国家或地区储备货币存货和以储备货币标价的资产(通常是储备国家的政府债券,如美国国债),香港以美元为储备货币,当这种储备货币存量大到足够包括整个基础货币也就是我们常说的M2,就可以实行货币局制度。以香港为例,确定港币与美元7.8汇率,如金本位制一样,发钞银行发行港币必须上缴等值美元为抵押,香港放弃对货币政策的控制,完全同步跟随美联储的货币政策,港币与美元在7.8 上下一个极小的范围内波动。
如果你看明白了联系汇率制,就清楚了只要香港有充足的外汇储备,没有偷发港币,港币几乎等同于美元,货币局制度的进一步就是美元化,1997年香港拥有960亿美元的外汇储备,财政状况良好,这种情况不存在对其联系汇率制攻击的基础。
以索罗斯为首的对冲基金在国际金融资本的支持下,横扫东南亚,作为四小龙之一的香港尤如惊弓之鸟,时刻警惕。值得注意的是在泰国发生金融危机的7月份,香港恒生指数不但没有跌,反而涨了。可惜香港当局没有注意到这个信号,上边通过对香港联系汇率制度的了解,我们知道尚不存在攻击港币的基础,你说靠发动货币战争横扫多个国家的索罗斯不知道吗?连英国都曾败在其手下,索罗斯当然清楚地很,不可能通过港币远期外汇掉期交易来牟利,那他攻击港币的目的何在呢?
明修栈道,暗渡陈仓,索罗斯一开始的盈利目标就锁定在做空恒指期货上了,所以1997年7月在泰国金融危机的情况下,香港恒指奇怪的不跌反涨就可以理解了,这正是国际对冲基金做空恒指的建仓期。
到 1997年10月,形势急转直下,香港危机开始爆发,其导火索源于10月20日,台湾地区央行放弃对新台币的支持,新台币随即贬值9%。台湾与香港联系并不紧密,但台湾外汇储备巨大,相当于1997年夏东南亚国家的外汇储备总和,台湾能倒,香港为何就不能输呢?在这种逻辑下,也有可能国际对冲基金在做空恒指的建仓已经完成。有笑话说,10月21日深夜,夜黑风高,香港财政司司长曾荫权和金管局局长任志刚分别接到一个神秘的电话,一个低沉的声音说,索罗斯要攻击港币了,21日22日在伦敦外汇市场上抛出了60亿美元的港币,把港币汇率压到7.75的警戒线之下,同时市场盛传香港联系汇率制度不保。
这时尤如惊弓之鸟的香港金融当局,看到泰国、菲律宾、印度尼西亚、马来西亚倒在货币危机下,台湾也已败下阵来,在这种思维定势的不断强化下,可能忘记了香港是执行与美元挂钩的货币局制度,港币几乎就等同于美元,谁有那么大胆子和能力攻击美元?谁又能用美元来攻击美元?曾荫权和任志刚如临大敌,索罗斯攻击港币,这一招在东南亚用过很多遍了,曾荫权和任志刚暗说,我早知应对之策,你的港币那里来?还不是从我这里的银行拆借的,10月23日中午,同业拆借利率急升到280%,同时打电话给银行打招呼窗口指导,严控短期拆借额度,让你借不起也借不到,想攻击港币,门都没有。
本来担心联系汇率不保的香港居民和外国投资者就已经开始抛售港币资产,尤其是港股,银根的突然收紧,短期利率的大幅提高,使股市雪上加霜,恒生指数当天暴跌10.4%,1997年 10月28日香港恒生指数再度暴跌13.4%,香港股市市值减少2.1万亿港币。有人质疑香港金融管理当局为何在这种情况下不坚持货币局制度,为市场紧急提供流动性,殊不知这正是香港金融管理当局应对攻击港币的措施,在索罗斯等国际对冲基金的指挥下,把香港恒生指数打下去了。此后两次的对港币的攻击,也让香港以同样的手法击退了,还有人说香港金融管理当局赢得这第一交锋的胜利,在我看来,所谓的攻击港币根本就不成立,香港金融当局完全在随着索罗斯的指挥棒跳舞,上当了都不知道,谈何胜利?
从香港金融管理局主席任志刚后来的描述,香港金融管理当局在1998年8月才明白过来,上当了。他这样写道:1998年8月,我们面临的形势更为复杂。投机者对我们的金融市场发起了联合的精心策划的攻击。投机者发现,在短期内通过集中性抛售港元,能够暂时抬升货币局制度下的利率,这将对股票价格施加向下的压力。通过短期内对这种货币施加压力并且抛售股票,即使他们不能冲破设定的汇率,他们也可能从股票指数期货合同上获取一笔收益。其实港府明白的太晚了,1998年8月13日香港恒生指数跌穿6600点,从1997年8月16000多点的高位下跌将近 10000点,此时离8月28日的恒指交割期时间已近,可以说胜败已定。
在1998年8月之前的四次对港币的攻击中,任志刚都以提高利率来应对,当时舆论叫他任一招,只此一招,而且还是错招。等任志刚明白过来后,就改变了招数,从外汇市场上低价通吃港币,8月5日炒家卖出200多亿港币,8月6日炒家又卖出200多亿港币,香港运用财政资金如数吃下,将汇率稳定在 7.75,同时转手存入银行,将利率也稳住了,这本是一开始就应采用的正确应对,这样炒家就无机可乘,还得赔上拆借利息。
8月14日明白外汇市场不过烟雾弹,股票市场和期货市场才是主战场的香港当局,毅然决然地决定以巨额外汇基金和土地基金入市干预,与索罗斯为首的国际炒家决一死战。在决定入市之前曾荫权曾在夜里静静地哭过两三次,深感压力巨大,如果失败,就是自己跳楼也无法挽回损失,与任志刚商量决定入市之后,随即向特首董建华提出建议,老板董建华不到半个小时就拍板,和他们斗一场。有关香港金融保卫战的盛况有关描写的文章已有很多,在这里我们就不做过多描述,只说说关键的一些东西, 8月24日恒生指数由港府入市前的6610点推高到7820点,随后的几天国际炒家和港府的交战进入白热化。
由于8月28日为股指期货交割期,迎来了首次决战,上午10点整开市后仅5分钟,股市的成交额就超过了39亿港元。半小时后,成交金额就突破了100 亿港元,到上午收市时,成交额已经达到400亿港元之巨,接近1997年8月29日创下的460亿港元日成交量历史最高纪录。下午开市后,抛售有增无减,成交量一路攀升,但恒指和期指始终维持在7800点以上。随着下午4点整的钟声响起,显示屏上不断跳动的恒指、期指、成交金额最终分别锁定在7829点、 7851点、790亿港元上。普遍的观点认为国际炒家在7500点卖空恒指8月合约,而结算点位收在7851点,国际炒家在做空恒指8月合约上巨亏。 1998年9月7日,香港金融管理局颁布了外汇、证券交易和结算的新规定,使炒家的投机大受限制。当日恒生指数飙升588点,以8076点报收。加上日元升值、东南亚金融市场趋稳等一系列因素,使投机炒家的资金、换汇成本大幅上升,不得不败退离场:9月8日,9月合约价格升到8220点。8月底转仓的期指合约要平仓退场,每张合约又要亏损4万港元。至此,国际炒家见大势已去,纷纷丢盔弃甲,落荒而逃。
在整个香港金融保卫战中港府投入资金 1180亿港币,有人预计索罗斯在香港阻击战中损失8亿美元,落荒而逃。实际情况真是如香港金融保卫战揭秘说的这样香港当局大获全胜吗?我们回顾一下,对香港的攻击开始于2007年10月,索罗斯在1994年就在精心准备对东南亚的攻击了,可以说1997年10月对香港发起攻击前一切准备工作都已做好了,以索罗斯对货币市场理解之精深,当然知道不可能在攻击港币中获利,攻击港币本来就是明修栈道,索罗斯的主战场就是股指期货,而在1997年8月香港恒生指数在16000点以上,无疑为其提供了做空恒指的建仓良机,有理由认为索罗斯有充分的时间在高位完成沽空恒指期货的建仓。
在1997年10 月下旬开始对了对所谓的港币开始攻击的时候,恒指在短短几天的暴跌,市值损失2.1万亿港币,这个时候索罗斯都不需要在对股票市场上对权重股进行建仓,即使有也是少量的用于打压的筹码,完全可以忽略不计,这个阶段其在沽空股指期货的获利几乎是纯利。在1998年8月之前类似的攻击已经发生了4次,每次香港金管局的任一招都是用同样的办法提高短期利率让索罗斯沽空恒指获利。
有股指期货的常识的朋友都知道,做空股指期货的主力一定要掌握足够数量的权重股筹码,否则就等于是毡板上的肉任人宰割了。分析恒生指数的走势,索罗斯等在港股市场对权重股建仓可能在10000点以下才开始,可能在1998年5月左右大规模建仓以对冲沽空期指的风险,6月7月恒生指数攀升到8000点左右,这时对冲基金再次大幅沽空恒指,到8月14日把恒指打到6610点,之前的19个交易日恒指急跌2000多点,每张合约可赚10多万港币,利润之高,让人难以想象。做空恒指期货,恒指每下跌1点,每张合约获利50港币,从索罗斯最初建仓的16000多点,每张合约可赚50多万港币,即使持有1万张合约,就赚了50多亿港币,即使最贪婪的人,在这个时候都应该是收获季节了,何况索罗斯这样的高人,1998年8月上旬应该就是索罗斯大量平仓的时间段,由于无法查到其沽空恒指的具体仓位,无法计算其究竟赚了多少钱。而按有的说法,索罗斯在1998年8月交割的沽空恒指合约中亏损12亿港币,8月交割的合约每张亏损额为3万多港币,也就是说索罗斯新开未平仓的合约应该在3万多张,其整个恒指沽空合约应在数十万张,其盈利难以计数。
对做空股指期货的主力来说,其在股市持有的权重股筹码主要是为保证其期指合约的安全,在大盘上涨时要能压得住盘,而往下打压时一般都会在低位及时回补筹码,有时我们会看到高买低卖觉得很难理解,对主力来说高买低卖之后,只要能在更低的价位接回来,其股票市值的损失就很小,如果上涨还有盈利。对做空股指期货的主力来说,在指数上下基本处于平衡的区间,其沽空期指的金额与其权重股筹码大致相当,以对冲风险。当其沽空的股指合约获利平仓之后,其对冲风险的权重股筹码就需要清仓,一般来说作为向下打压的手段,不以盈利为目的。
分析道这里,我想你大约已经明白了,在恒指6600点到8000点之间,对冲基金的沽空期指的主力合约大部分已获利平仓了。这时最重要的任务就是,为对冲风险而持有的权重股的大把股票如何出货是最关键的了,任志刚等香港金融管理当局在 1997年10月到1998年8月之前索罗斯等对冲基金四次攻击港币都没整明白对冲基金获利的主战场,在最后的关键时刻一下明白了,我都怀疑这是索罗斯告诉他们的。索罗斯竟然在恒指7500点建仓,区区不到4万张1998 年8月交割的沽空恒指合约完全是诱饵,以掩护1000亿权重股筹码完成胜利大逃亡。曾荫权与任志刚终于知道了对冲基金的秘密,于是大哭几场之后,痛下决心与索罗斯决一死战,颇有点抬棺而战的悲壮。面对索罗斯的疯狂抛售,港府动用充裕的外汇基金和土地基金,不惜一切代价挂单接下对冲基金的所有抛单,还乘胜追击,拉高股价,让索罗斯卖了个好价钱,其实当时港府可能急晕了头,没有去查一下沽空期指合约究竟有多少张?其实应该可以查到的。从事后知道的索罗斯在8月 28日交割的沽空股指期货合约损失12亿港币来看,不到4万张,每张30多万港币,总市值不到150亿港币,而港府却掏出了1180亿港币还拉高股价在短短的十个交易日里接下了以索罗斯为首的对冲基金的筹码,帮助其实现了胜利大逃亡的目标。
也许有朋友还是不太明白,从香港保卫战的激烈程度,港府接下的这1180亿港币的筹码应该基本都是国际炒家抛出的,虽然其中难免有其它散户震出来的筹码,索罗斯这些国际炒家的筹码应该在1000亿港币以上,据统计索罗斯在香港保卫战中损失8亿美元,也就是差不多60亿港币,这其中包括拆借港币的短期利息,蓝筹股筹码打压的损失,交易手续费,最终作为诱饵的沽空期指8月合约损失的12亿港币。说到这里你该明白了索罗斯以60亿港币的代价在短短10个交易日,完成了1000亿港币筹码的出货这种不可完成的任务,而且还实现了股指由6600点到7829点的上涨,这天文数字的筹码完成出货,而且基本上是在最后几天出在了最高点,股指却涨了将近20%,股价拉高的收益都不止60亿港币了。这是何等的高明,你说港府取得了香港保卫战的胜利了吗?
港府的确取得了1998年8月以及9月恒指期货合约的胜利,而且其投入的1180亿港币的盈富基金在几年之后也取得了不错的收益。我们再看看索罗斯为首的国际炒家们赚了多少钱?上边已分析过,在最后出货的过程中利用香港的金融保卫战,实现了高位出货,我们假设这一过程已将其损失和成本弥补,其前期在沽空股指期货的盈利就是净利润。根据前面的分析,在平衡区间,对冲基金的沽空期指的头寸基本与其权重股筹码持平以对冲风险,现在知道了8000点左右其股票市值在1000亿港币以上,对应的期指空头尺寸也在1000 亿以上,恒生期指每点对应50港币,8000点的每张合约为40万港币,也就是说索罗斯为首的国际炒家持有的恒生期指沽空合约在25万张以上,如果全部在 16000点以上建仓,每张合约的盈利空间是8000点,即使并非全部都是在高位建仓,如我们前边分析,其大部分仓位应该是在高位建的,低估一点平均盈利空间为6000点,那么每张合约的利润为30万港币,25万多张合约的盈利至少在750亿港币之上,将近100亿美元。由于无法知道索罗斯为首的国际炒家的期指空头尺寸究竟多少,以前分析为估算,但相比香港股市数万亿港币的市值损失,这也不算什么了。
通过我的仔细分析,不知你是否已经明白所谓的1998年香港金融保卫战,自始至终都是在索罗斯指挥棒的指挥下跳舞,要知道对冲基金以杠杆操作为主,他主要的钱都是融资借来的,按现在高盛和摩根斯坦利融资的情况看,一般是10%的年利率,等上四五年慢慢出货无异于自杀,把索罗斯精妙无比的出货当成仓皇出逃,所谓的胜利不过把恒指从16000点跌到8000点这拦腰一刀的空间都不计算,以1998年8月9月这最后2个月的交割来计算,完全是自欺欺人的阿 Q 胜利法。
索罗斯对泰国、菲律宾、印度尼西亚和马来西亚等亚洲四小虎的金融攻击不能称之为骗局,那完全是肆无忌惮,赤裸裸的明火执杖的抢劫。对香港的攻击才称得上是精妙无比、精心筹划的世纪大骗局,索罗斯在香港兴高采烈的庆祝胜利声中,偷偷的拎着装满美元的钱箱回国了,走前还不忘很绅士地对曾荫权与任志刚说热烈祝贺你们取得香港金融保卫战的胜利,你们成功地捍卫了香港的联系汇率制(心说不能告诉你们联系汇率下港币就是美元,攻击港币本来就是扯淡),大胆决策动用 1180亿港币将恒指守住了7800点(心说不能提醒你们恒指是从16000点下来的,不这样谁有能力能接下我的抛盘,)使我沽空恒指的合约还亏损平仓 (心说不能提醒你们我的主力合约早就平仓盈利了,这点不过是引诱你们接盘的诱饵,这年头舍不得孩子套不了狼呀),让我除了钱什么都没剩下,等你们庆祝完胜利,有空来美国帮我数钱,我实在搞不清究竟赚了多少,再次祝贺你们取得胜利。
题后话:
香港当年悍然救市,费力不讨好,国际社会一直批评香港违背自由市场经济原则,看看当今的美国这个自由市场经济原则的领袖和捍卫者的作为,香港金融保卫战要真正战胜索罗斯简直简单如儿戏:对港币的抛售有多少接多少,然后存进银行,对所有香港银行提供无限量流动性支持,这样索罗斯再借多少港币都是白送利息,转手又都回银行了,而且银行港币要多少有多少就怕你索罗斯不来借,这样既维持汇率不变,资金充裕利率也不会抬高,你想借机打压股市,门都没有;发布禁空令,禁止做空恒指期货,此前做空恒指期货的获利为不当获利,予以没收;至于索罗斯买的股票管都不用管它了,除了亏本卖没别的办法,否则只有为香港的长期稳定繁荣作贡献了。你说高明不高明,只有不按规则出牌才能灭了这帮家伙,卑鄙是卑鄙者的通行证。
Tuesday, June 15, 2010
Pass 70-536
pass 70-505 (Windows Form Application) on 2010-08-05, score: 978
pass 70-563 (Designing and Developing Windows Applications) on 2010-09-11, score: 929
pass 70-561 (ADO.NET) on 2010-10-17, score: 895
pass 70-502 (WPF 65Q) on 2010-11-20, score: 914
pass 70-503 (WCF 45Q) on 2011-01-30, score: 754
pass 70-504 (WF 70Q) on 2011-02-27, score: 1000
Friday, June 4, 2010
Best advice for your preparation for 70-536
As is known to everyone, if you learn and master each and every aspect of the subject and get a hand on experience on it, and then you will not have any problems, that is to say, you absolutely will get 70-536!!But, we could not become a master in .net framework-application Development Foundation in singe half year or one year.
When you read it here, maybe you’ll be confused and ask how the candidate for MCTS 70-536 could make it in a couple of months?? Of course, we can make it if you follow the steps as this article said below:
To pass the exams, the 70-536 candidates should firstly focus on important areas. So, you should pay attention to the official site since the guideline is subject to change at any time without prior notice and at the sole discretion of Microsoft. Generally speaking, there won’t be substantial change.
Here is the guide for 70-536:
1. Developing applications that use system types and collections (15 percent)
2. Implementing service processes, threading, and application domains in a .NET Framework application (11 percent)
3. Embedding configuration, diagnostic, management, and installation features into a .NET Framework application (14 percent)
4. Implementing serialization and input/output functionality in a .NET Framework application (18 percent)
5. Improving the security of .NET Framework applications by using the .NET Framework security features (20 percent)
6. Implementing interoperability, reflection, and mailing functionality in a .NET Framework application (11 percent)
7. Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application (11 percent)
Of course, the detail information won’t be listed; however, it could help us decide how much time we should spend in each major topic area according to the relative weight on the exam.
So, we have known what object we’ll achieve, and then we should have the best materials for us to prepare 70-536.
1. Good online training websites. They can provider many resources for us to better know the objectives and better prepare the exams. All Microsoft exams have a set of objectives outlining the topics you need to understand to become successful in the exam. It is a good practice to visit the Microsoft’s site to check the latest exam details, because these objectives keep on changing from time to time.
2. Outstanding software that really trains for this exam.
3. Good books .Here is the two books. Step by step book which I would recommend you to start with:
1. The Microsoft Certified Application Specialist Study Guide
2. MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0 Foundation
So, after all preparations are done, we need to make a plan to prepare the exam!!! The following plan is just for your reference, and you should find the best suit for yourself.
1. Fix your daily hours of study and set a deadline for completing the entire contents. This will help you prepare efficiently for the exam.
2. Once you have created your study plan, you should attempt the diagnostic tests, and you should concentrate your studies on these objectives, as a thorough knowledge of the topics included in them is essential for passing the exam.
3. Study Notes: The Study notes are organized according to the actual test objectives. It helps you understand the topics clearly and systematically, assist you in difficult areas and organize your studies. They provide in-depth knowledge of different topics and help you become a master in the respective field.
4. Practice questions are necessary to get an overview on the type of questions you will encounter in the actual exams. The more you practice, the better understanding you will have on the type of questions you will face. Microsoft has included different types of questions like ‘hot area’, ‘build list and reorder’, ‘drag and drop’, and the latest ’simulation questions’ in its exams.
5. Quiz: The exam quiz helps you learn the technical terms, concepts and definitions, etc., that are essential for the real exams. You can set your own time for the quiz, and can even set the time allowed for each question to appear. Customized pop quizzes can also be created by selecting the topics and number of questions from each topic, so that you can prepare for the real exam quickly and effectively.
6. Track your progress: You should keep track of your progress over time by going through the detailed test report provided at the end of each practice test.
7. Register for the test: Nothing beats than setting a deadline. Therefore, you should register for the test at least two weeks in advance. This helps in building the tempo and keeps you more focused and determined.
8. Quickly review just before taking the test: As your exam day nears, it is a good time to go through a quick review on all the tips, notes, exam alerts and summary given at the end of each chapter. Glance through the topic briefly if you have doubts. Be relaxed and have a good amount of sleep.
P.S.
Maybe many candidates have those questions like would some types of questions on MS be on the exams??
I think if it’s covered in your study materials (i.e. MS Press book), then it’s probably on the exam. Note that MS doesn’t release the number or exact types of questions on the exams. If you use a MS Press book, then it comes with the MeasureUp practice exams. Those are the types of questions you’ll see on the actual exam. No matter what types of questions in your paper, you will succeed in 70-536 as long as you know all subjects fully! How much of the knowledge you grasp is the key in your exams.
Finally ,wish you successful in your exams !!!
Wednesday, April 14, 2010
how to send email from .Net using gmail account
client.Port = 587;
client.Credentials = new NetworkCredential("youname", "password");
client.EnableSsl = true;
MailMessage message = new MailMessage(
new MailAddress("To@gmail.com", "John"), //To
new MailAddress("CC@gmail.com", "Smith")); //CC
message.Bcc.Add(new MailAddress("BCC@com.com"));
message.Subject = "....";
message.Body = "body";
Attachment att = new Attachment(@"c:\abc.cs");
message.Attachments.Add(att);c
client.Send(message);
Friday, March 26, 2010
In response to new rules, GoDaddy to stop registering domain names in China
Thursday, March 25, 2010
GoDaddy.com, the world's largest domain name registration company, told lawmakers Wednesday that it will cease registering Web sites in China in response to intrusive new government rules that require applicants to provide extensive personal data, including photographs of themselves.
The rules, the company said, are an effort by China to increase monitoring and surveillance of Web site content and could put individuals who register their sites with the firm at risk. The company also said the rules will have a "chilling effect" on new domain name registrations.
GoDaddy's move follows Google's announcement Monday that it will no longer censor search results on its site in China. Analysts and human rights advocates have warned that China's insistence on censorship and control over information is becoming a serious barrier to trade.
"GoDaddy and Google deserve more than praise for doing the right thing in China -- they deserve our government's support," said Rep. Christopher H. Smith (R-N.J.), who has sponsored a bill that would prevent U.S. companies from sharing personal user information with "Internet-restricting" countries.
In December, China began to enforce a new policy that required any registrant of a new .cn domain name to provide a color, head-and-shoulders photograph and other business identification, including a Chinese business registration number and physical, signed registration forms. That data was to be forwarded to the China Internet Network Information Center (CNNIC), a quasi-governmental agency. Most domain name registries require only a name, address, telephone number and e-mail address.
"We were immediately concerned about the motives behind the increased level of registrant verification being required," Christine N. Jones, general counsel of the Go Daddy Group, told the Congressional-Executive Commission on China on Wednesday. "The intent of the procedures appeared, to us, to be based on a desire by the Chinese authorities to exercise increased control over the subject matter of domain name registrations by Chinese nationals."
GoDaddy has been registering domain names since 2000 and has more than 40 million under management.
Jones said China was the first government to retroactively seek additional verification and documentation of registrants.
Jones also said GoDaddy customers with Chinese domain names have recently been attacked more frequently than in the past. The sites targeted tend to be those "deemed not appropriate" by Beijing -- sites that contain content about the Tiananmen Square uprising or human rights, for instance.
"When our sites get shut down in China, we are never told why . . . and it's impossible to know why," Jones said.
The Chinese Embassy in Washington did not respond to a request for comment.
Arvind Ganesan, business and human rights director at Human Rights Watch, said China's new rules are yet another example of the country tightening its censorship policies and undermining the ability of U.S. companies to operate freely.
"The underlying intent is, if you're engaging in political speech, we want to know who's engaging in it and what Web site is behind it," Ganesan said. "This is a way the Chinese government can send a chilling message to people that they shouldn't speak freely online. It's forcing us companies to be both the censor and the spy on behalf of the Chinese government."
Jones said GoDaddy's decision to stop registering new domains was unrelated to Google's recent decision.
"With all due respect, this has nothing to do with Google," she said. She added that the company had been deliberating what it would do about its business in China before Google's announcement.
"We decided we didn't want to be agents of China," she said.
At Wednesday's hearing, Alan Davidson, Google's director of public policy, said governments worldwide should develop new rules to combat unfair trade barriers online and should make Internet freedom part of the criteria for receiving development aid. He noted that the number of governments that routinely censor the Internet has grown from a handful in 2002 to more than 40 today.
Proud for GOOGLE
关于谷歌中国的最新声明
2010 年3 月 23 日
David Drummond, SVP, Corporate Development and Chief Legal Officer
今年1月12日,我们在本博客上宣布,Google及另外二十余家美国公司受到了来自中国的、复杂的网络攻击,在对这些攻击进 行深入调查的过程中,通过我们所收集到的证据表明,几十个与中国有关的人权人士的Gmail帐号定期受到第三方的侵入,而这大部分侵入是通过安装在他们电脑上的钓鱼软件或恶意软件进行的。这些攻击以及它们所暴露的网络审查问题,加上去年以来中国进一步限制网络言论自由,包括 对FaceBook、Twitter、YouTube、Google Docs 和 Blogger 等网站的持续屏蔽,使我们做出结论:我们不能继续在Google.cn搜索结果上进行自我审查。
从今天早上开始,我们已停止了在Google.cn搜索服务上的自我审查,包括 Google Search (网页搜索)、Google News(资讯搜索)和Google Images (图片搜索)。 访问 Google.cn 的用 户从现在开始将被指向Google.com.hk,在这个域名上,我们将提供未经审查的简体中文搜索结果,这些为中国大陆用户设计的服务将通过我们在香港的服务器实现。香港地区的用户还将继续通过Google.com.hk获得跟现在一样的、未经审查的繁体中文搜索服务。在我们进行迁移的过程中,由于香港服务器负荷的增加以及这些变化的复杂程度,用户可能会发现搜索速度变慢,或发现某些产品暂时不能访问。
实施我们做出的在Google.cn上停止审查搜索结果的承诺是一个十分艰难的过程。我们希望全球尽可能多的用户都能访问到我们的服务,包括在中国大陆的用户。中国政府在与我们讨论的过程中已经十分明确地表示,自我审查是一个不可谈判的法律要求。为此,我们相信,一个解决我们所面临挑战的可行方案是在Google.com.hk上提供未经审查的简体中文搜索结果——它完全符合法律要求,同时也有助于提高中国大陆用户对信息的访问。我们十分希望中国政府尊重我们的这一决定,尽管我们知道,用户对Google服务的访问有可能随时被阻止。为此,我们将密切监测网址访问问题,并制作了一个新页面,用户可以实时地了解到在中国哪些Google服务是可用的。
至于Google的广泛的业务运营,我们计划继续在中国的研发工作,并将保留销售团队,然而销售团队的规模显然部分取决于中国大陆用户能否访问Google.com.hk 。最后,我们要清楚表明:所有这些决定都是由美国的管理团队做出和实施的,没有任何一位中国员工能够、或者应该为这些决定负责。自我们在1月份发布博客以 来,尽管面临着众多的不确定性和困难,他们仍然坚守在工作岗位,专注于服务我们的中国用户和客户。我们为拥有这样的员工感到深深的骄傲。
©2010 Google
Friday, March 19, 2010
Buy Dell laptop Inspiron 15 (1564) on March 15
Processor: NEW 2010 Intel®Core™ i3 - 330M
Memory: 4GB Shared Dual Channel DDR3 at 1066MHz
LCD Panel: 15.6" HD WLED
Video Card Intel® HD Graphics
Hard Drive 320GB, 5400 RPM
System Color Ice Blue IMR
Operating System Genuine Windows® 7 Home Premium, 64bit
Network Card Integrated 10/100 Network Card
Adobe Reader Adobe® Acrobat® Reader 9.0
DVD+RW Drive 8X CD/DVD Burner (Dual Layer DVD+/-R Drive)
Sound High Definition Audio 2.0
Wireless Dell Wireless 1397 802.11g Half Mini-Card
Camera Integrated 1.3M Pixel Webcam W/Facial Recognition
Office Software Microsoft® Works 9
Anti-Virus McAfee SecurityCenter, 15-Months
Battery Lithium Ion Battery (6 cell)
Hardware Support Services 1 Year Limited Warranty w/1 Year Return To Depot Service
Price: 629 plus tax
Tuesday, March 16, 2010
Wednesday, March 10, 2010
Disney Photo Pass Low Res Hack
Each picture has an unique id, its a long sequence of numbers and letters and what Disney tries to do is to obfuscate it so that its very difficult to get to. Off of the preview, there is no right click functionality, so you have to be creative.
The hard part is getting the image id. I've already took the liberty of finding you the link to get the image, so all you need to do is fill in the image id.
1. Make sure your using firefox 3.x, if your not go download it here
2. Your gonna install a plugin/add-on called Firebug, you can get it here
3. Goto the first page where you see your first picture, goto Firefox > Tools > Firebug > Open Firebug
4. From there you will see this complicated mess of data, what we will be looking for is under the "DOM" tab.
5. From there go all the way down to where it says "PhotoInfo" on the left hand side directly across from it you will see "ObjectImageId" - That is the magic key to each individual image.
6. Copy that and open a new window and use this url:
http://www.disneyphotopass.com/API/photostore/previewEdits.pix?ImageID=
alternate url:
http://www.disneyphotopass.com/API/photostore/Getlowresimage.pix?ImageID=
7. Paste the id at the end of this string. so your resulting URL should look something like:
http://www.disneyphotopass.com/API/photostore/previewEdits.pix?ImageID=c21a90dc-6415-43a2-96e1-e8940eb71f16
Sunday, February 28, 2010
Canada won Olympic men's hockey gold medal in OT
Canadian men’s hockey has a golden Olympic shimmer once again.
The Canadian national team hung on for a stressful 3-2 victory in overtime to give the country a second Olympic gold medal to celebrate in eight years.
Goalies
Martin Brodeur
Roberto Luongo
Marc-Andre Fleury
Defense
Chris Pronger (A)
Shea Weber
Brent Seabrook
Scott Niedermayer (C)
Dan Boyle
Drew Doughty
Duncan Keith
Forwards
Sydney Crosby (A)
Jerome Iginla (A)
Jonathan Toews
Rick Nash
Eric Staal
Mike Richards
Brenden Morrow
Dany Heatley
Joe Thornton
Ryan Getzlaf
Patrick Marleau
Corey Perry
Patrice Bergeron
Monday, February 8, 2010
Competition Bureau Seeks to Prohibit Anti-competitive Real Estate Rules
OTTAWA, February 8, 2010 — The Competition Bureau announced today that it will challenge rules imposed by the Canadian Real Estate Association (CREA) that limit consumer choice and prevent innovation in the market for residential real estate services.
The Commissioner of Competition has determined that CREA’s rules restrict the ability of consumers to choose the real estate services they want, forcing them to pay for services they do not need. The rules also prevent real estate agents from offering more innovative service and pricing options to consumers. The Commissioner’s application to the Competition Tribunal seeks to strike down these anti-competitive rules.
“Selling a home is one of the largest financial transactions that most Canadians make in their lifetime,” said Melanie Aitken, Commissioner of Competition. “Consumers should be able to choose which services they want to buy in order to facilitate that transaction, including lower-cost options. While the Bureau would have preferred to resolve this matter amicably, CREA’s leadership was unwilling to agree to changes that would have opened up competition, and offered options for consumers and real estate agents.”
The Bureau’s challenge is against rules imposed by CREA on agents who list properties on the Multiple Listing Service (MLS) system. The overwhelming majority of real estate transactions in Canada make use of the MLS system, which includes important information available only to CREA members. Before listing a property on MLS, agents must agree to comply with CREA’s restrictions on the service options they provide to Canadian consumers.
For example, under CREA’s rules, agents are prohibited from offering consumers the option of simply paying a fee for an agent to list a home on the MLS system. Instead, all consumers looking to list a property on MLS must purchase a pre-determined set of additional services from a real estate agent, such as the presentation of offers and negotiation of a final deal.
“The Bureau is focused on striking down these anti-competitive rules, so that real estate agents wishing to offer innovative services can do so, and consumers can benefit from greater choice,” said Commissioner Aitken. “While the market will ultimately determine prices for residential real estate services, we expect that if the Tribunal strikes down the anti-competitive restrictions, there will be downward pressure on real estate fees in Canada.”
Once filed with the Competition Tribunal, the full text of the Bureau’s filing will be available on the Tribunal Web site.
The Competition Bureau is an independent law enforcement agency that contributes to the prosperity of Canadians by protecting and promoting competitive markets and enabling informed consumer choice.
Competition watchdog says realtor rules limit choice
The Ottawa-based agency said Monday it will challenge rules created by the Canadian Real Estate Association (CREA) that “limit consumer choice” and stop real estate agents from being more “innovative” in the services they offer.
The Bureau’s target is the multiple listing service, the system owned by CREA which is estimated to control about 90% of all transactions in Canada.
“We are concerned CREA has passed rules that are anti-competitive.” said Melanie Aitken, commissioner of competition. “Our case is about letting consumers choose, let agents offer difference choices to consumers. We have been in dialogue with CREA for almost three years now and intense negotiations since October.”
One of the concerns of the Competition Bureau is that, under CREA’s rules, agents are prohibited from offering consumers the option of simply paying a fee to list a home on the MLS system. Consumers have to opt for an entire suite of services that come with a commission rate of about 5%, though it differs from province to province.
The commissioner has filed an application with the Competition Tribunal to strike down what it calls CREA’s anti-competitive rules. No financial penalty is being sought.
“CREA views the Commissioner’s decision as surprising and disappointing,” Dale Ripplinger, president of CREA, said in a statement. “We do not agree with the Bureau’s position that certain CREA rules are anti-competitive, either as a matter of fact or as a matter of law.”
If victorious, the move by the Competition Bureau should result in lower rates for consumers who choose to buy limited services from a realtor. “In our experience if you introduce choice, you introduce innovation, you introduce enhanced competition, there is downward pressure on prices,” Ms. Aitken said.
“In United States, where they have dismantled rules quite similar to these, competition is flourishing.”
Real estate author and former member of parliament Garth Turner said the days of CREA’s dominance are all but over. “The writing is on the wall for MLS. There have been shots across the bow and CREA has fought back. Now the government is making it clear this looks an awful lot like a monopoly and it is hard to defend. You look what happened in the United States and it was bound to happen in Canada.”
Mr. Turner expects the MLS will eventually completely open up with consumers able to list a home on their own, even without using a broker. “This is an interim step until we get to that end result.”
Lawyer Lawrence Dale, a part owner of Realtysellers (Ontario) Ltd., which sued the Toronto Real Estate Board (TREB) and Canadian Real Estate Association, alleging the two organizations were forcing the company to raise the price it charged home buyers and sellers, said the rules have been restricting agents from offering different services. Realtysellers offered a program that allowed you to get an MLS listing for $695. The two sides settled their lawsuit out of court.
“This upped the ante,” said Mr. Dale, about the Bureau taking CREA to a tribunal. “They built this great system but when you build a great system and become a monopoly, you use some of your liberties. That’s competition law. You can’t abuse your dominance.”
Don Lawby, chief executive of Century 21 Canada, said it’s too early to know what the end result will be. He said some local boards may choose to opt out of the MLS system.
“One thing I can tell, is this is a competitive industry. There are every kind of commission structure out there. There have been discount brokers as long as I have been in this industry,” said Mr. Lawby. He said the action by the Competition Bureau will open the door for discounters to charge an MLS access fee, but provide no services.
Michael Polzler, senior vice-president of Re/Max Ontario-Atlantic Canada, said he’s not all that worried about competition from discount brokers offering very limited service.
“We believe people should have options when they are selling their home. It is the largest transaction that most people make and most will continue to use the services of a realtor,” said Mr. Polzler.
gmarr@nationalpost.com
Read more: http://www.cbc.ca/fp/story/2010/02/08/2536948.html#ixzz0f0CRAuNB
Tuesday, January 19, 2010
Learning .NET Regular Expressions with Expresso
Learning .NET Regular Expressions with Expresso
Did you ever wonder what Regular Expressions are all about and want to gain a basic understanding quickly? My goal is to get you up and running with a basic understanding of regular expressions within 30 minutes. The reality is that regular expressions aren't as complex as they look. The best way to learn is to start writing and experimenting. After your first half hour, you should know a few of the basic constructs and be able to design and use regular expressions in your programs or web pages. For those of you who get hooked, there are many excellent resources available to further your education.
What the Heck is a Regular Expression Anyway?
I'm sure you are familiar with the use of "wildcard" characters for pattern matching. For example, if you want to find all the Microsoft Word files in a Windows directory, you search for "*.doc
", knowing that the asterisk is interpreted as a wildcard that can match any sequence of characters. Regular expressions are just an elaborate extension of this capability.
In writing programs or web pages that manipulate text, it is frequently necessary to locate strings that match complex patterns. Regular expressions were invented to describe such patterns. Thus, a regular expression is just a shorthand code for a pattern. For example, the pattern "\w+" is a concise way to say "match any non-null strings of alphanumeric characters". The .NET framework provides a powerful class library that makes it easy to include regular expressions in your applications. With this library, you can readily search and replace text, decode complex headers, parse languages, or validate text.
A good way to learn the arcane syntax of regular expressions is by starting with examples and then experimenting with your own creations. This tutorial introduces the basics of regular expressions, giving many examples that are included in an Expresso library file. Expresso can be used to try out the examples and to experiment with your own regular expressions.
Let's get started!
Some Simple Examples
Searching for Elvis
Suppose you spend all your free time scanning documents looking for evidence that Elvis is still alive. You could search with the following regular expression:
1.elvis
Find elvisThis is a perfectly valid regular expression that searches for an exact sequence of characters. In .NET, you can easily set options to ignore the case of characters, so this expression will match "Elvis", "ELVIS", or "eLvIs". Unfortunately, it will also match the last five letters of the word "pelvis". We can improve the expression as follows:
2. \belvis\b
Find elvis as a whole word
Now things are getting a little more interesting. The "\b
" is a special code that means, "match the position at the beginning or end of any word". This expression will only match complete words spelled "elvis" with any combination of lower case or capital letters.
Suppose you want to find all lines in which the word "elvis" is followed by the word "alive." The period or dot ".
" is a special code that matches any character other than a newline. The asterisk "*
" means repeat the previous term as many times as necessary to guarantee a match. Thus, ".*
" means "match any number of characters other than newline". It is now a simple matter to build an expression that means "search for the word 'elvis' followed on the same line by the word 'alive'."
3. \belvis\b.*\balive\b
Find text with "elvis" followed by "alive"
With just a few special characters we are beginning to build powerful regular expressions and they are already becoming hard for we humans to read.
Let's try another example.
Determining the Validity of Phone Numbers
Suppose your web page collects a customer's seven-digit phone number and you want to verify that the phone number is in the correct format, "xxx-xxxx", where each "x" is a digit. The following expression will search through text looking for such a string:
4. \b\d\d\d-\d\d\d\d
Find seven-digit phone number
Each "\d
" means "match any single digit". The "-
" has no special meaning and is interpreted literally, matching a hyphen. To avoid the annoying repetition, we can use a shorthand notation that means the same thing:
5. \b\d{3}-\d{4}
Find seven-digit phone number a better way
The "{3}
" following the "\d
" means "repeat the preceding character three times".
Let's learn how to test this expression.
Expresso
If you don't find regular expressions hard to read you are probably an idiot savant or a visitor from another planet. The syntax can be imposing for anyone, including those who use regular expressions frequently. This makes errors common and creates a need for a simple tool for building and testing expressions. Many such tools exist, but I'm partial to my own, Expresso, originally launched on the CodeProject. Version 2.0 is shown here. For later versions, check the Ultrapico website.
To get started, install Expresso and select the Tutorial from the Windows Program menu. Each example can be selected using the tab labeled "Expression Library".
Figure 1. Expresso running example 5
Start by selecting the first example, "1. Find Elvis". Click Run Match and look at the TreeView on the right. Note there are several matches. Click on each to show the location of the match in the sample text. Run the second and third examples, noting that the word "pelvis" no longer matches. Finally, run the fourth and fifth examples; both should match the same numbers in the text. Try removing the initial "
\b
" and note that part of a Zip Code matched the format for a phone number.Basics of .NET Regular Expressions
Let's explore some of the basics of regular expressions in .NET.
Special Characters
You should get to know a few characters with special meaning. You already met "\b
", ".
", "*
", and "\d
". To match any whitespace characters, like spaces, tabs, and newlines, use "\s
" . Similarly, "\w
" matches any alphanumeric character.
Let's try a few more examples:
6. \ba\w*\b
Find words that start with the letter a
This works by searching for the beginning of a word (\b), then the letter "a", then any number of repetitions of alphanumeric characters (\w*), then the end of a word (\b).
7. \d+
Find repeated strings of digits
Here, the "+" is similar to "*", except it requires at least one repetition.
8. \b\w{6}\b
Find six letter words
Try these in Expresso and start experimenting by inventing your own expressions. Here is a table of some of the characters with special meaning:
| Match any character except newline |
| Match any alphanumeric character |
| Match any whitespace character |
| Match any digit |
| Match the beginning or end of a word |
| Match the beginning of the string |
| Match the end of the string |
Table 1. Commonly used special characters for regular expressions
In the beginning
The special characters "^
" and "$
" are used when looking for something that must start at the beginning of the text and/or end at the end of the text. This is especially useful for validating input in which the entire text must match a pattern. For example, to validate a seven-digit phone number, you might use:
9. ^\d{3}-\d{4}$
Validate a seven-digit phone number
This is the same as example (5), but forced to fill the whole text string, with nothing else before or after the matched text. By setting the "Multiline" option in .NET, "^
" and "$
" change their meaning to match the beginning and end of a single line of text, rather than the entire text string. The Expresso example uses this option.
Escaped characters
A problem occurs if you actually want to match one of the special characters, like "^
" or "$
". Use the backslash to remove the special meaning. Thus, "\^
", "\.
", and "\\
", match the literal characters "^
", ".
", and "\
", respectively.
Repetitions
You've seen that "{3}
" and "*
" can be used to indicate repetition of a single character. Later, you'll see how the same syntax can be used to repeat entire subexpressions. There are several other ways to specify a repetition, as shown in this table:
| Repeat any number of times |
| Repeat one or more times |
| Repeat zero or one time |
| Repeat n times |
| Repeat at least n, but no more than mtimes |
| Repeat at least n times |
Table 2. Commonly used quantifiers
Let's try a few more examples:
10. \b\w{5,6}\b
Find all five and six letter words
11. \b\d{3}\s\d{3}-\d{4}
Find ten digit phone numbers
12. \d{3}-\d{2}-\d{4}
Social security number
13. ^\w*
The first word in the line or in the text
Try the last example with and without setting the "Multiline" option, which changes the meaning of "^
".
Character Classes
It is simple to find alphanumerics, digits, and whitespace, but what if we want to find anything from some other set of characters? This is easily done by listing the desired characters within square brackets. Thus, "[aeiou]
" matches any vowel and "[.?!]
" matches the punctuation at the end of a sentence. In this example, notice that the ".
" And "?
" lose their special meanings within square brackets and are interpreted literally. We can also specify a range of characters, so "[a-z0-9]
" means, "match any lowercase letter of the alphabet, or any digit".
Let's try a more complicated expression that searches for telephone numbers.
14. \(?\d{3}[) ]\s?\d{3}[- ]\d{4}
A ten digit phone number
This expression will find phone numbers in several formats, like "(800) 325-3535" or "650 555 1212". The "\(?
" searches for zero or one left parentheses, "[) ]
" searches for a right parenthesis or a space. The "\s?" searches for zero or one whitespace characters. Unfortunately, it will also find cases like "650) 555-1212" in which the parenthesis is not balanced. Below, you'll see how to use alternatives to eliminate this problem.
Negation
Sometimes we need to search for a character that is NOT a member of an easily defined class of characters. The following table shows how this can be specified.
| Match any character that is NOT alphanumeric |
| Match any character that is NOT whitespace |
| Match any character that is NOT a digit |
| Match a position that is NOT the beginning or end of a word |
| Match any character that is NOT x |
| Match any character that is NOT one of the characters aeiou |
Table 3. How to specify what you don't want
15. \S+
All strings that do not contain whitespace characters
Later, we'll see how to use "lookahead" and "lookbehind" to search for the absence of more complex patterns.
Alternatives
To select between several alternatives, allowing a match if either one is satisfied, use the pipe "|
" symbol to separate the alternatives. For example, Zip Codes come in two flavors, one with 5 digits, the other with 9 digits and a hyphen. We can find either with this expression:
16. \b\d{5}-\d{4}\b|\b\d{5}\b
Five and nine digit Zip Codes
When using alternatives, the order is important since the matching algorithm will attempt to match the leftmost alternative first. If the order is reversed in this example, the expression will only find the 5 digit Zip Codes and fail to find the 9 digit ones. We can use alternatives to improve the expression for ten digit phone numbers, allowing the area code to appear either delimited by whitespace or parenthesis:
17. (\(\d{3}\)|\d{3})\s?\d{3}[- ]\d{4}
Ten digit phone numbers, a better way
Grouping
Parentheses may be used to delimit a subexpression to allow repetition or other special treatment. For example:
18. (\d{1,3}\.){3}\d{1,3}
A simple IP address finder
The first part of the expression searches for a one to three digit number followed by a literal period "\.
". This is enclosed in parentheses and repeated three times using the "{3}
" quantifier, followed by the same expression without the trailing period.
Unfortunately, this example allows IP addresses with arbitrary one, two, or three digit numbers separated by periods even though a valid IP address cannot have numbers larger than 255. It would be nice to arithmetically compare a captured number N to enforce N<256,>
19. ((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)
IP finder
Expresso Analyzer View
Figure 2. Expresso's analyzer view showing example 17
Expresso has a feature that diagrams expressions in a Tree structure, explaining what each piece means. When debugging an expression, this can help zoom in on the part that is causing trouble. Try this by selecting example (17) and then using the Analyze button. Select nodes in the tree and expand them to explore the structure of this regular expression as shown in the figure. After highlighting a node, you can also use the Partial Match or Exclude Match buttons to run a match using just the highlighted portion of the regular expression or using the regular expression with the highlighted portion excluded.
When subexpressions are grouped with parentheses, the text that matches the subexpression is available for further processing in a computer program or within the regular expression itself. By default, groups are numbered sequentially as encountered in reading from left to right, starting with 1. This automatic numbering can be seen in Expresso's skeleton view or in the results shown after a successful match.
A "backreference" is used to search for a recurrence of previously matched text that has been captured by a group. For example, "\1
" means, "match the text that was captured by group 1". Here is an example:
20. \b(\w+)\b\s*\1\b
Find repeated words
This works by capturing a string of at least one alphanumeric character within group 1 "(\w+)
", but only if it begins and ends a word. It then looks for any amount of whitespace "\s*
" followed by a repetition of the captured text "\1
" ending at the end of a word.
It is possible to override the automatic numbering of groups by specifying an explicit name or number. In the above example, instead of writing the group as "(\w+)
", we can write it as "(?
" to name this capture group "Word
". A backreference to this group is written "\k
". Try this example:
21. \b(?
Capture repeated word in a named group
Test this in Expresso and expand the match results to see the contents of the named group.
Using parentheses, there are many special purpose syntax elements available. Some of the most common are summarized in this table:
Captures | |
| Match exp and capture it in an automatically numbered group |
| Match exp and capture it in a group named name |
| Match exp, but do not capture it |
Lookarounds | |
| Match any position preceding a suffix exp |
| Match any position following a prefix exp |
| Match any position after which the suffix exp is not found |
| Match any position before which the prefix exp is not found |
Comment | |
| Comment |
Table 4. Commonly used Group Constructs
We've already talked about the first two. The third "(?:
exp)
" does not alter the matching behavior, it just doesn't capture it in a named or numbered group like the first two.
Positive Lookaround
The next four are so-called lookahead or lookbehind assertions. They look for things that go before or after the current match without including them in the match. It is important to understand that these expressions match a position like "^
" or "\b
" and never match any text. For this reason, they are known as "zero-width assertions". They are best illustrated by example:
"(?=
exp)
" is the "zero-width positive lookahead assertion". It matches a position in the text that precedes a given suffix, but doesn't include the suffix in the match:
22. \b\w+(?=ing\b)
The beginning of words ending with "ing"
"(?<=
exp)
" is the "zero-width positive lookbehind assertion". It matches the position following a prefix, but doesn't include the prefix in the match:
23. (?<=\bre)\w+\b
The end of words starting with "re"
Here is an example that could be used repeatedly to insert commas into numbers in groups of three digits:
24. (?<=\d)\d{3}\b
Three digits at the end of a word, preceded by a digit
Here is an example that looks for both a prefix and a suffix:
25. (?<=\s)\w+(?=\s)
Alphanumeric strings bounded by whitespace
Negative Lookaround
Earlier, I showed how to search for a character that is not a specific character or the member of a character class. What if we simply want to verify that a character is not present, but don't want to match anything? For example, what if we are searching for words in which the letter "q" is not followed by the letter "u"? We could try:
26. \b\w*q[^u]\w*\b
Words with "q" followed by NOT "u"
Run the example and you will see that it fails when "q" is the last letter of a word, as in "Iraq". This is because "[^q]" always matches a character. If "q" is the last character of the word, it will match the whitespace character that follows, so in the example the expression ends up matching two whole words. Negative lookaround solves this problem because it matches a position and does not consume any text. As with positive lookaround, it can also be used to match the position of an arbitrarily complex subexpression, rather than just a single character. We can now do a better job:
27. \b\w*q(?!u)\w*\b
Search for words with "q" not followed by "u"
We used the "zero-width negative lookahead assertion", "(?!exp)", which succeeds only if the suffix "exp" is not present. Here is another example:
28. \d{3}(?!\d)
Three digits not followed by another digit
Similarly, we can use "(?
exp)"
, the "zero-width negative lookbehind assertion", to search for a position in the text at which the prefix "exp" is not present:
29. (?
Strings of 7 alphanumerics not preceded by a letter or space
Here is one more example using lookaround:
30. (?<=<(\w+)>).*(?=<\/\1>)
Text between HTML tags
This searches for an HTML tag using lookbehind and the corresponding closing tag using lookahead, thus capturing the intervening text but excluding both tags.
Comments please
Another use of parentheses is to include comments using the "(?#comment)" syntax. A better method is to set the "Ignore Pattern Whitespace" option, which allows whitespace to be inserted in the expression and then ignored when the expression is used. With this option set, anything following a number sign "#" at the end of each line of text is ignored. For example, we can format the preceding example like this:
31. Text between HTML tags, with comments
(?<= # Search for a prefix, but exclude it <(\w+)> # Match a tag of alphanumerics within angle brackets
) # End the prefix
.* # Match any text
(?= # Search for a suffix, but exclude it
<\/\1> # Match the previously captured tag preceded by "/"
) # End the suffix
Greedy and Lazy
When a regular expression has a quantifier that can accept a range of repetitions (like ".*
"), the normal behavior is to match as many characters as possible. Consider the following regular expression:
32. a.*b
The longest string starting with a and ending with b
If this is used to search the string "aabab", it will match the entire string "aabab". This is called "greedy" matching. Sometimes, we prefer "lazy" matching in which a match using the minimum number of repetitions is found. All the quantifiers in Table 2 can be turned into "lazy" quantifiers by adding a question mark "?
". Thus "*?
" means "match any number of repetitions, but use the smallest number of repetitions that still leads to a successful match". Now let's try the lazy version of example (32):
33. a.*?b
The shortest string starting with a and ending with b
If we apply this to the same string "aabab" it will first match "aab" and then "ab".
| Repeat any number of times, but as few as possible |
| Repeat one or more times, but as few as possible |
| Repeat zero or one time, but as few as possible |
| Repeat at least n, but no more than m times, but as few as possible |
| Repeat at least n times, but as few as possible |
Table 5. Lazy quantifiers
What did we leave out?
I've described a rich set of elements with which to begin building regular expressions; but I left out a few things that are summarized in the following table. Many of these are illustrated with additional examples in the project file. The example number is shown in the left-hand column of this table.
# | Syntax | Description |
| Bell character | |
| Normally a word boundary, but within a character class it means backspace | |
| Tab | |
34 |
| Carriage return |
| Vertical tab | |
| Form feed | |
35 |
| New line |
| Escape | |
36 |
| Character whose ASCII octal code is nnn |
37 |
| Character whose hexadecimal code is nn |
38 |
| Character whose Unicode is nnnn |
39 |
| Control N character, for example carriage return (Ctrl-M) is \cM |
40 |
| Beginning of a string (like ^ but does not depend on the multiline option) |
41 |
| End of string or before \n at end of string (ignores multiline) |
| End of string (ignores multiline) | |
42 |
| Beginning of the current search |
43 |
| Any character from the Unicode class named name, for example \p{IsGreek} |
| Greedy subexpression, also known as a non-backtracking subexpression. This is matched only once and then does not participate in backtracking. | |
44 |
| Balancing group. This is complicated but powerful. It allows named capture groups to be manipulated on a push down/pop up stack and can be used, for example, to search for matching parentheses, which is otherwise not possible with regular expressions. See the example in the project file. |
45 |
| Change the regular expression options for the subexpression exp |
46 |
| Change the regular expression options for the rest of the enclosing group |
| The subexpression exp is treated as a zero-width positive lookahead. If it matches at this point, the subexpression yes becomes the next match, otherwise no is used. | |
| Same as above but with an empty no expression | |
| This is the same syntax as the preceding case. If name is a valid group name, the yes expression is matched if the named group had a successful match, otherwise the no expression is matched. | |
47 |
| Same as above but with an empty no expression |
Table 6. Everything we left out. The left-hand column shows the number of an example in the project file that illustrates this construct.
Conclusion
We've given many examples to illustrate the essential features of .NET regular expressions, emphasizing the use of a tool like Expresso to test, experiment, and learn by example. If you get hooked, there are many online resources available to help you go further. You can start your search at the Ultrapico web site. If you want to read a book, I suggest the latest edition of Mastering Regular Expressions, by Jeffrey Friedl.
There are also a number of nice articles on The Code Project including the following tutorials: