??xml version="1.0" encoding="utf-8" standalone="yes"?>久久天天日天天操综合伊人av,久久久久国产精品嫩草影院,国产精品岛国久久久久http://www.shnenglu.com/aqazero/category/3167.htmlzh-cnWed, 27 Aug 2008 05:12:20 GMTWed, 27 Aug 2008 05:12:20 GMT60桃李不言Q下自成y?/title><link>http://www.shnenglu.com/aqazero/archive/2008/08/27/60134.html</link><dc:creator>brent</dc:creator><author>brent</author><pubDate>Wed, 27 Aug 2008 04:01:00 GMT</pubDate><guid>http://www.shnenglu.com/aqazero/archive/2008/08/27/60134.html</guid><wfw:comment>http://www.shnenglu.com/aqazero/comments/60134.html</wfw:comment><comments>http://www.shnenglu.com/aqazero/archive/2008/08/27/60134.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/aqazero/comments/commentRss/60134.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/aqazero/services/trackbacks/60134.html</trackback:ping><description><![CDATA[有个控g叫CTreeListCtrlQ我用了好久了,暗爽了很久,最作者是来敬仰啊<br><br>最q无意中发现Q作者TigerX原来pd球村中国ӞƧ耶?br>地址Qhttp://www.codeproject.com/KB/tree/ctreelistctrl.aspx<br><br>q以为codeproject上没其它中国土h呢,华h倒是知道有好几个?br><br>Z在codeproject发了文章,讲xml序列化复杂对象模型的Q门可罗雀啊?br>http://www.codeproject.com/KB/cs/xmlable.aspx<br><br>嗯,很有差别?br><br> <img src ="http://www.shnenglu.com/aqazero/aggbug/60134.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/aqazero/" target="_blank">brent</a> 2008-08-27 12:01 <a href="http://www.shnenglu.com/aqazero/archive/2008/08/27/60134.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>coding hall of shamehttp://www.shnenglu.com/aqazero/archive/2008/08/15/58947.htmlbrentbrentFri, 15 Aug 2008 08:55:00 GMThttp://www.shnenglu.com/aqazero/archive/2008/08/15/58947.htmlhttp://www.shnenglu.com/aqazero/comments/58947.htmlhttp://www.shnenglu.com/aqazero/archive/2008/08/15/58947.html#Feedback0http://www.shnenglu.com/aqazero/comments/commentRss/58947.htmlhttp://www.shnenglu.com/aqazero/services/trackbacks/58947.htmlAlthough recently I was working on an embedded system, and saw revision dates going back more than ten years. I was quite surprised at how well-structured and commented the code was. Very easy to modify. One of my co-workers told me that was mainly because of the team leader, who held regular code walk-thrus, and kept a "coding hall of shame" on an internal web site.

brent 2008-08-15 16:55 发表评论
]]>
Platform Warshttp://www.shnenglu.com/aqazero/archive/2008/05/14/49817.htmlbrentbrentWed, 14 May 2008 06:10:00 GMThttp://www.shnenglu.com/aqazero/archive/2008/05/14/49817.htmlhttp://www.shnenglu.com/aqazero/comments/49817.htmlhttp://www.shnenglu.com/aqazero/archive/2008/05/14/49817.html#Feedback0http://www.shnenglu.com/aqazero/comments/commentRss/49817.htmlhttp://www.shnenglu.com/aqazero/services/trackbacks/49817.html

brent 2008-05-14 14:10 发表评论
]]>
软g观念革命:交互设计_Nhttp://www.shnenglu.com/aqazero/archive/2008/04/29/48426.htmlbrentbrentTue, 29 Apr 2008 06:19:00 GMThttp://www.shnenglu.com/aqazero/archive/2008/04/29/48426.htmlhttp://www.shnenglu.com/aqazero/comments/48426.htmlhttp://www.shnenglu.com/aqazero/archive/2008/04/29/48426.html#Feedback1http://www.shnenglu.com/aqazero/comments/commentRss/48426.htmlhttp://www.shnenglu.com/aqazero/services/trackbacks/48426.html

brent 2008-04-29 14:19 发表评论
]]>
msdn code; visualwebguihttp://www.shnenglu.com/aqazero/archive/2008/04/02/46006.htmlbrentbrentWed, 02 Apr 2008 03:05:00 GMThttp://www.shnenglu.com/aqazero/archive/2008/04/02/46006.htmlhttp://www.shnenglu.com/aqazero/comments/46006.htmlhttp://www.shnenglu.com/aqazero/archive/2008/04/02/46006.html#Feedback0http://www.shnenglu.com/aqazero/comments/commentRss/46006.htmlhttp://www.shnenglu.com/aqazero/services/trackbacks/46006.html
http://www.visualwebgui.com/
how did they do that?


brent 2008-04-02 11:05 发表评论
]]>
book notehttp://www.shnenglu.com/aqazero/archive/2008/03/28/45607.htmlbrentbrentFri, 28 Mar 2008 02:53:00 GMThttp://www.shnenglu.com/aqazero/archive/2008/03/28/45607.htmlhttp://www.shnenglu.com/aqazero/comments/45607.htmlhttp://www.shnenglu.com/aqazero/archive/2008/03/28/45607.html#Feedback0http://www.shnenglu.com/aqazero/comments/commentRss/45607.htmlhttp://www.shnenglu.com/aqazero/services/trackbacks/45607.htmlhttp://www.china-pub.com/37008
看了LQ没觉得哪里体现?#8220;高效”2字,只是他排错的环境实在是恶劣,其实试人员应该比开发h员牛逼才对,代码Zh会写Q排错不是h做的Q需要的知识储备比光写写代码需要的多得多了?br>L里D的工人分金条的例子题目是错的Q还看到一个错别字...但俺对这U授Z渔的写法很有好感?br>

brent 2008-03-28 10:53 发表评论
]]>
numerical computationhttp://www.shnenglu.com/aqazero/archive/2008/03/17/44693.htmlbrentbrentMon, 17 Mar 2008 07:39:00 GMThttp://www.shnenglu.com/aqazero/archive/2008/03/17/44693.htmlhttp://www.shnenglu.com/aqazero/comments/44693.htmlhttp://www.shnenglu.com/aqazero/archive/2008/03/17/44693.html#Feedback0http://www.shnenglu.com/aqazero/comments/commentRss/44693.htmlhttp://www.shnenglu.com/aqazero/services/trackbacks/44693.htmlhttp://www.scilab.org/



brent 2008-03-17 15:39 发表评论
]]>
SQLite; .Net<- InterProcess ->MFC; Windows Services in Action; a 2D CAD application;http://www.shnenglu.com/aqazero/archive/2008/03/05/43726.htmlbrentbrentWed, 05 Mar 2008 02:22:00 GMThttp://www.shnenglu.com/aqazero/archive/2008/03/05/43726.htmlhttp://www.shnenglu.com/aqazero/comments/43726.htmlhttp://www.shnenglu.com/aqazero/archive/2008/03/05/43726.html#Feedback0http://www.shnenglu.com/aqazero/comments/commentRss/43726.htmlhttp://www.shnenglu.com/aqazero/services/trackbacks/43726.htmlSQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.
http://www.sqlite.org/
Light, Free, Fast, Cross platform.
witten in C, and there are a lot of wrappers, find what you need here: http://www.sqlite.org/cvstrac/wiki?p=SqliteWrappers

http://www.codeproject.com/KB/cpp/SQLite_Server.aspx
Implementing Server/Client architecture for that great SQLite! with visual studio C++ 2005

http://www.codeproject.com/KB/cs/InterprocessCommunicator.aspx
Interprocess Communication Between .NET and MFC using WM_COPYDATA

http://www.codeproject.com/KB/cs/WindowsServicesInAction1.aspx
http://www.codeproject.com/KB/cs/WindowsServicesInAction2.aspx
Windows Services in Action
Windows Services Hand by Hand...

http://www.codeproject.com/KB/cs/OpenS-CAD.aspx
OpenS-CAD, a simple 2D CAD application. <-- just so so

http://www.codeproject.com/KB/cs/DiskAnalyzer.aspx
I don't care about disk, i do care about the pie chart and tree gird view.










brent 2008-03-05 10:22 发表评论
]]>
firefoxhttp://www.shnenglu.com/aqazero/archive/2008/02/04/42517.htmlbrentbrentMon, 04 Feb 2008 06:51:00 GMThttp://www.shnenglu.com/aqazero/archive/2008/02/04/42517.htmlhttp://www.shnenglu.com/aqazero/comments/42517.htmlhttp://www.shnenglu.com/aqazero/archive/2008/02/04/42517.html#Feedback0http://www.shnenglu.com/aqazero/comments/commentRss/42517.htmlhttp://www.shnenglu.com/aqazero/services/trackbacks/42517.html2)http://cs.senecac.on.ca/~david.humphrey/writing/debugging-firefox.html




brent 2008-02-04 14:51 发表评论
]]>
ui patternshttp://www.shnenglu.com/aqazero/archive/2008/02/01/42341.htmlbrentbrentFri, 01 Feb 2008 06:24:00 GMThttp://www.shnenglu.com/aqazero/archive/2008/02/01/42341.htmlhttp://www.shnenglu.com/aqazero/comments/42341.htmlhttp://www.shnenglu.com/aqazero/archive/2008/02/01/42341.html#Feedback0http://www.shnenglu.com/aqazero/comments/commentRss/42341.htmlhttp://www.shnenglu.com/aqazero/services/trackbacks/42341.html

brent 2008-02-01 14:24 发表评论
]]>
HTML document in vc6.0http://www.shnenglu.com/aqazero/archive/2007/09/07/31747.htmlbrentbrentFri, 07 Sep 2007 06:00:00 GMThttp://www.shnenglu.com/aqazero/archive/2007/09/07/31747.htmlhttp://www.shnenglu.com/aqazero/comments/31747.htmlhttp://www.shnenglu.com/aqazero/archive/2007/09/07/31747.html#Feedback0http://www.shnenglu.com/aqazero/comments/commentRss/31747.htmlhttp://www.shnenglu.com/aqazero/services/trackbacks/31747.htmlsimple way to capture whole html as an image


http://codeguru.earthweb.com/cpp/i-n/ieprogram/displayinginformation/article.php/c7273/
HTML Editor for VC++ 6.0



brent 2007-09-07 14:00 发表评论
]]>
gpc urlhttp://www.shnenglu.com/aqazero/archive/2007/08/20/30442.htmlbrentbrentMon, 20 Aug 2007 09:29:00 GMThttp://www.shnenglu.com/aqazero/archive/2007/08/20/30442.htmlhttp://www.shnenglu.com/aqazero/comments/30442.htmlhttp://www.shnenglu.com/aqazero/archive/2007/08/20/30442.html#Feedback0http://www.shnenglu.com/aqazero/comments/commentRss/30442.htmlhttp://www.shnenglu.com/aqazero/services/trackbacks/30442.html
http://www.cs.man.ac.uk/~toby/alan/software/



brent 2007-08-20 17:29 发表评论
]]>
reading note 2006-12http://www.shnenglu.com/aqazero/archive/2006/12/03/15910.htmlbrentbrentSat, 02 Dec 2006 16:28:00 GMThttp://www.shnenglu.com/aqazero/archive/2006/12/03/15910.htmlhttp://www.shnenglu.com/aqazero/comments/15910.htmlhttp://www.shnenglu.com/aqazero/archive/2006/12/03/15910.html#Feedback0http://www.shnenglu.com/aqazero/comments/commentRss/15910.htmlhttp://www.shnenglu.com/aqazero/services/trackbacks/15910.html 如何获取汉字的拼?
http://blog.csdn.net/cpu88/archive/2004/11/26/195315.aspx
步骤Q?
//得到拼音Q包括多韻I
 A:   用输入法生成?win2000)"C:\Program Files\Windows NT\Accessories\Imegen.exe"
       逆{换拼韌入法文gC:\WINNT\SYSTEM32\WINPY.MB
      会生成一个C:\WINNT\SYSTEM32\WINPY.txt文g(U?WINPY.txt文g)
B:   WINPY.txt文g里面是  ?汉字拼音列表5万多?除去词组 有汉?万多个(含多韻I
C:   汉字可以转换成某中编码可以自己构造编码方?保证一个汉字对应一个编?U编码方法)
      ?byte[] uniCode = new String(temp).getBytes(“GB2312?;
      WINPY.txt里面所有的汉字变成~码。得到汉字编?拼音对应表(U汉字编码表Q?br />        XXXX0,a    //XXXX0是某个汉字的~码
        XXYX2,o    //XXYX2是某个汉字的~码
 D:  汉字~码表按~码排序Q编码表按编码大排序?br />      ~码表分l(方便查询 Q?而且得到分组的标志?br /> E: 查询汉字拼音  汉字进行编码(按自q~码ҎQ?br />      用编码在~码表中查询可以得到拼韻I查询时在~码表中的某个分l中查询Q而不是在所有编码中查询。速度很快?br />//得到首字W??北京'  得到 'bj'            '呆子'得到  'd[a]z '  //多音
//排序  有了拼音 可以按一些常见的排序Ҏ排序

如何在C++中集成Lua脚本(LuaPlus?:
http://ly4cn.teeta.com/blog/data/44939.html
据说无法调用虚函数。有Ҏ。有I再看看?br />http://luaplus.org/

字符串到其他格式的{?
CString   timestr   =   "2000q?4?5?;  
  int   a,b,c   ;  
  sscanf(timestr.GetBuffer(timestr.GetLength()),"%dq?d?d?,&a,&b,&c);  
  CTime   time(a,b,c,0,0,0);  
ANSI兼容Q我太孤陋寡M...

RMI for c++?:
http://www.codeproject.com/threads/RMI_For_Cpp.asp
反正目前没这个需要?br />
声音引擎QaudiereQ支持跨q_:
gZ错?br />http://www.shnenglu.com/gogoplayer/archive/2006/11/29/15763.html
http://sourceforge.net/projects/audiere/
wxWidget的wxSound支持windows和unix?br />其它关于sound:
http://www.opensound.com/oss.html
http://www.libsdl.org/

Why You Should Turn Down That Job Offer
http://www.computerworld.com/action/article.do?command=viewArticleBasic&articleId=9005602&pageNumber=1
You will be the fifth person to have held the job in the past three years.
Why is this job vacant?
Is the turnover rate high for this position?
What's typically the next career step for those with this job?
You will clash with the corporate culture.
You will be bored -- or overwhelmed -- in the role.
You will not be able to move forward.

may not be reason enough to turn down a job:
You will earn less than you did before.
You will be in the car for two hours each day.
You will receive a “demotion?in title.

计算Int最大最?br />http://www.shnenglu.com/Winux32/archive/2006/12/01/15853.html
通常我们会用CRT提供l我们的一个头文g<limits.h>中预定义宏INT_MAX, INT_MIN, UINT_MAX来定义int的最大最g边给出由计算得出q些值的ҎQ其他数据类型同?br />unsigned  int  GetUnsignedIntMax()
{
     return   ~ 0 ;
}

signed  int  GetSignedIntMax()
{
     return  (static_cast < unsigned  int > ( ~ 0 ))  >>   1 ;
}

signed  int  GetSignedIntMin()
{
    signed  int  i  =   - 1 ;
    if  (i  &   1 )
        return   - ( (static_cast < unsigned  int > ( ~ 0 ))  >>   1  )  -   1 ;
    else
        return   - ( (static_cast < unsigned  int > ( ~ 0 ))  >>   1  );
}
E微解释一下,前两个没有什么好说的Q最后一个要考虑是two complementq是one complement
如果是前者,有这样一个计公式,~X + 1= -XQ即一个数取反加一表示q个数所对应的负?br />

How Skype & Co. get round firewalls
cool..
http://www.heise-security.co.uk/articles/82481
先Copyq来再说.

The hole trick

How Skype & Co. get round firewalls

Peer-to-peer software applications are a network administrator's nightmare. In order to be able to exchange packets with their counterpart as directly as possible they use subtle tricks to punch holes in firewalls, which shouldn't actually be letting in packets from the outside world.

Increasingly, computers are positioned behind firewalls to protect systems from internet threats. Ideally, the firewall function will be performed by a router, which also translates the PC's local network address to the public IP address (Network Address Translation, or NAT). This means an attacker cannot directly adress the PC from the outside - connections have to be established from the inside.

This is of course a problem when two computers behind NAT firewalls require to talk directly to each other - if, for example, their users want to call each other using Voice over IP (VoIP). The dilemma is clear - whichever party calls the other, the recipient's firewall will decline the apparent attack and will simply discard the data packets. The telephone call doesn't happen. Or at least that's what a network administrator would expect.

Punched

But anyone who has used the popular internet telephony software Skype knows that it works as smoothly behind a NAT firewall as it does if the PC is connected directly to the internet. The reason for this is that the inventors of Skype and similar software have come up with a solution.

Naturally every firewall must also let packets through into the local network - after all the user wants to view websites, read e-mails, etc. The firewall must therefore forward the relevant data packets from outside, to the workstation computer on the LAN. However it only does so, when it is convinced that a packet represents the response to an outgoing data packet. A NAT router therefore keeps tables of which internal computer has communicated with which external computer and which ports the two have used.

The trick used by VoIP software consists of persuading the firewall that a connection has been established, to which it should allocate subsequent incoming data packets. The fact that audio data for VoIP is sent using the connectionless UDP protocol acts to Skype's advantage. In contrast to TCP, which includes additional connection information in each packet, with UDP, a firewall sees only the addresses and ports of the source and destination systems. If, for an incoming UDP packet, these match an NAT table entry, it will pass the packet on to an internal computer with a clear conscience.

Switching

The switching server, with which both ends of a call are in constant contact, plays an important role when establishing a connection using Skype. This occurs via a TCP connection, which the clients themselves establish. The Skype server therefore always knows under what address a Skype user is currently available on the internet. Where possible the actual telephone connections do not run via the Skype server; rather, the clients exchange data directly.

Let's assume that Alice wants to call her friend Bob. Her Skype client tells the Skype server that she wants to do so. The Skype server already knows a bit about Alice. From the incoming query it sees that Alice is currently registered at the IP address 1.1.1.1 and a quick test reveals that her audio data always comes from UDP port 1414. The Skype server passes this information on to Bob's Skype client, which, according to its database, is currently registered at the IP address 2.2.2.2 and which, by preference uses UDP port 2828.

Bob's Skype program then punches a hole in its own network firewall: It sends a UDP packet to 1.1.1.1 port 1414. This is discarded by Alice's firewall, but Bob's firewall doesn't know that. It now thinks that anything which comes from 1.1.1.1 port 1414 and is addressed to Bob's IP address 2.2.2.2 and port 2828 is legitimate - it must be the response to the query which has just been sent.

Now the Skype server passes Bob's coordinates on to Alice, whose Skype application attempts to contact Bob at 2.2.2.2:2828. Bob's firewall sees the recognised sender address and passes the apparent response on to Bob's PC - and his Skype phone rings.

Doing the rounds

This description is of course somewhat simplified - the details depend on the specific properties of the firewalls used. But it corresponds in principle to our observations of the process of establishing a connection between two Skype clients, each of which was behind a Linux firewall. The firewalls were configured with NAT for a LAN and permitted outgoing UDP traffic.

Linux' NAT functions have the VoIP friendly property of, at least initially, not changing the ports of outgoing packets. The NAT router merely replaces the private, local IP address with its own address - the UDP source port selected by Skype is retained. Only when multiple clients on the local network use the same source port does the NAT router stick its oar in and reset the port to a previously unused value. This is because each set of two IP addresses and ports must be able to be unambiguously assigned to a connection between two computers at all times. The router will subsequently have to reconstruct the internal IP address of the original sender from the response packet's destination port.

Other NAT routers will try to assign ports in a specific range, for example ports from 30,000 onwards, and translate UDP port 1414, if possible, to 31414. This is, of course, no problem for Skype - the procedure described above continues to work in a similar manner without limitations.

It becomes a little more complicated if a firewall simply assigns ports in sequence, like Check Point's FireWall-1: the first connection is assigned 30001, the next 30002, etc. The Skype server knows that Bob is talking to it from port 31234, but the connection to Alice will run via a different port. But even here Skype is able to outwit the firewall. It simply runs through the ports above 31234 in sequence, hoping at some point to stumble on the right one. But if this doesn't work first go, Skype doesn't give up. Bob's Skype opens a new connection to the Skype server, the source port of which is then used for a further sequence of probes.

Nevertheless, in very active networks Alice may not find the correct, open port. The same also applies for a particular type of firewall, which assigns every new connection to a random source port. The Skype server is then unable to tell Alice where to look for a suitable hole in Bob's firewall.

However, even then, Skype doesn't give up. In such cases a Skype server is then used as a relay. It accepts incoming connections from both Alice and Bob and relays the packets onwards. This solution is always possible, as long as the firewall permits outgoing UDP traffic. It involves, however, an additional load on the infrastructure, because all audio data has to run through Skype's servers. The extended packet transmission times can also result in an unpleasant delay.

Use of the procedure described above is not limited to Skype and is known as "UDP hole punching". Other network services such as the Hamachi gaming VPN application, which relies on peer-to-peer communication between computers behind firewalls, use similar procedures. A more developed form has even made it to the rank of a standard - RFC 3489 "Simple Traversal of UDP through NAT" (STUN) describes a protocol which with two STUN clients can get around the restrictions of NAT with the help of a STUN server in many cases. The draft Traversal Using Relay NAT (TURN) protocol describes a possible standard for relay servers.

DIY hole punching

With a few small utilities, you can try out UDP hole punching for yourself. The tools required, hping2 and netcat, can be found in most Linux distributions. Local is a computer behind a Linux firewall (local-fw) with a stateful firewall which only permits outgoing (UDP) connections. For simplicity, in our test the test computer remote was connected directly to the internet with no firewall.

Firstly start a UDP listener on UDP port 14141 on the local/1 console behind the firewall:

local/1# nc -u -l -p 14141

An external computer "remote" then attempts to contact it.

remote# echo "hello" | nc -p 53 -u local-fw 14141

However, as expected nothing is received on local/1 and, thanks to the firewall, nothing is returned to remote. Now on a second console, local/2, hping2, our universal tool for generating IP packets, punches a hole in the firewall:

local/2# hping2 -c 1 -2 -s 14141 -p 53 remote

As long as remote is behaving itself, it will send back a "port unreachable" response via ICMP - however this is of no consequence. On the second attempt

remote# echo "hello" | nc -p 53 -u local-fw 14141

the netcat listener on console local/1 then coughs up a "hello" - the UDP packet from outside has passed through the firewall and arrived at the computer behind it.

Network administrators who do not appreciate this sort of hole in their firewall and are worried about abuse, are left with only one option - they have to block outgoing UDP traffic, or limit it to essential individual cases. UDP is not required for normal internet communication anyway - the web, e-mail and suchlike all use TCP. Streaming protocols may, however, encounter problems, as they often use UDP because of the reduced overhead.

Astonishingly, hole punching also works with TCP. After an outgoing SYN packet the firewall / NAT router will forward incoming packets with suitable IP addresses and ports to the LAN even if they fail to confirm, or confirm the wrong sequence number (ACK). Linux firewalls at least, clearly fail to evaluate this information consistently. Establishing a TCP connection in this way is, however, not quite so simple, because Alice does not have the sequence number sent in Bob's first packet. The packet containing this information was discarded by her firewall.

HashCode推荐法
《Effective Java?br />1,int result = 17;
2,Ҏ个重要数据成?Equals中用到的)Q计int c:
boolean : c = f?0:1;
byte,int,char,short : c = (int)f
long c = (int)(f^(f>>>32));
float : c = Float.floatToIntBits(f);
double : long l = (int)(f^(f>>>32));c = (int)(l^(l>>>32));
其它reference : c = f.hashCode();
3,result = 37*result+c;

正则表达式语?br />遍了MSDN2002中关于正则表辑ּ的文章,居然找不到正则表辑ּ语法Q气L了?br />贴过来。{载自某h的{载的转蝲的{?...

  正则表达?regular expression)描述了一U字W串匚w的模式,可以用来查一个串是否含有某种子串、将匚w的子串做替换或者从某个串中取出W合某个条g的子串等?br />   列目录时Q dir *.txt或ls *.txt中的*.txt?ins>?/ins>是一个正则表辑ּ,因ؓq里*与正则式?的含义是不同的?

  Z于理解和记忆Q先从一些概念入手,所有特D字W或字符l合有一个总表在后面,最后一些例子供理解相应的概c?/p>

正则表达?/h3>
  是由普通字W(例如字符 a ?zQ以及特D字W(UCؓ元字W)l成的文字模式。正则表辑ּ作ؓ一个模板,某个字W模式与所搜烦的字W串q行匚w?br />   可以通过在一对分隔符之间攑օ表达式模式的各种lg来构造一个正则表辑ּQ即/expression/

普通字W?/h3>
  由所有那些未昑ּ指定为元字符的打印和非打印字W组成。这包括所有的大写和小写字母字W,所有数字,所有标点符号以及一些符受?

非打印字W?/h3>
字符 含义
\cx 匚w由x指明的控制字W。例如, \cM 匚w一?Control-M 或回车符。x 的值必Mؓ A-Z ?a-z 之一。否则,?c 视ؓ一个原义的 'c' 字符?/td>
\f 匚w一个换늬。等价于 \x0c ?\cL?/td>
\n 匚w一个换行符。等价于 \x0a ?\cJ?/td>
\r 匚w一个回车符。等价于 \x0d ?\cM?/td>
\s 匚wMI白字符Q包括空根{制表符、换늬{等。等价于 [ \f\n\r\t\v]?/td>
\S 匚wM非空白字W。等价于 [^ \f\n\r\t\v]?/td>
\t 匚w一个制表符。等价于 \x09 ?\cI?/td>
\v 匚w一个垂直制表符。等价于 \x0b ?\cK?/td>

Ҏ字符


  所谓特D字W,是一些有Ҏ含义的字W,如上面说?*.txt"中的*Q简单的说就是表CZQ何字W串的意思。如果要查找文g名中有*的文Ӟ则需要对Q进行{义,卛_其前加一个\。ls \*.txt。正则表辑ּ有以下特D字W?br />
特别字符说明
$匚w输入字符串的l尾位置。如果设|了 RegExp 对象?Multiline 属性,?$ 也匹?'\n' ?'\r'。要匚w $ 字符本nQ请使用 \$?/td>
( )标记一个子表达式的开始和l束位置。子表达式可以获取供以后使用。要匚wq些字符Q请使用 \( ?\)?/td>
*匚w前面的子表达式零ơ或多次。要匚w * 字符Q请使用 \*?/td>
+匚w前面的子表达式一ơ或多次。要匚w + 字符Q请使用 \+?/td>
.匚w除换行符 \n之外的Q何单字符。要匚w .Q请使用 \?/td>
[ 标记一个中括号表达式的开始。要匚w [Q请使用 \[?/td>
?匚w前面的子表达式零ơ或一ơ,或指明一个非贪婪限定W。要匚w ? 字符Q请使用 \??/td>
\
^匚w输入字符串的开始位|,除非在方括号表达式中使用Q此时它表示不接受该字符集合。要匚w ^ 字符本nQ请使用 \^?/td>
{标记限定W表辑ּ的开始。要匚w {Q请使用 \{?/td>
|指明两项之间的一个选择。要匚w |Q请使用 \|?/td>


  构造正则表辑ּ的方法和创徏数学表达式的Ҏ一栗也是用多U元字符与操作符小的表辑ּl合在一h创徏更大的表辑ּ。正则表辑ּ的组件可以是单个的字W、字W集合、字W范围、字W间的选择或者所有这些组件的Ll合?/strong>


限定W?/h3>
  限定W用来指定正则表辑ּ的一个给定组件必要出现多少ơ才能满_配。有*??或{n}或{n,}或{n,m}?U?br /> *??限定W都是贪婪的Q因为它们会可能多的匹配文字,只有在它们的后面加上一?可以实现非贪婪或最匹配?br />   正则表达式的限定W有Q?br />
字符 描述
* 匚w前面的子表达式零ơ或多次。例如,zo* 能匹?"z" 以及 "zoo"? {h于{0,}?/td>
+
?
{n} n 是一个非负整数。匹配确定的 n ơ。例如,'o{2}' 不能匚w "Bob" 中的 'o'Q但是能匚w "food" 中的两个 o?/td>
{n,} n 是一个非负整数。至匹配n ơ。例如,'o{2,}' 不能匚w "Bob" 中的 'o'Q但能匹?"foooood" 中的所?o?o{1,}' {h?'o+'?o{0,}' 则等价于 'o*'?/td>
{n,m} m ?n 均ؓ非负整数Q其中n <= m。最匹?n ơ且最多匹?m ơ。例如,"o{1,3}" 匹?"fooooood" 中的前三?o?o{0,1}' {h?'o?'。请注意在逗号和两个数之间不能有空根{?/td>

定位W?/h3>
  用来描述字符串或单词的边界,^?分别指字W串的开始与l束Q\b描述单词的前或后边界Q\B表示非单词边界?ins>不能对定位符使用限定W?/ins>

选择


  用圆括号所有选择ҎhQ相ȝ选择之间用|分隔。但用圆括号会有一个副作用Q是相关的匹配会被缓存,此时可用?:攑֜W一个选项前来消除q种副作用?br />   其中?:是非捕获元之一Q还有两个非捕获元是?=?!Q这两个q有更多的含义,前者ؓ正向预查Q在M开始匹配圆括号内的正则表达式模式的位置来匹配搜索字W串Q后者ؓ负向预查Q在M开始不匚w该正则表辑ּ模式的位|来匚w搜烦字符丌Ӏ?

后向引用


  对一个正则表辑ּ模式或部分模式两Ҏ加圆括号导致相兛_配存储到一个时缓冲区中,所捕获的每个子匚w都按照在正则表达式模式中从左臛_所遇到? 内容存储。存储子匚w的缓冲区~号?1 开始,q箋~号直至最?99 个子表达式。每个缓冲区都可以?'\n' 讉KQ其?n Z个标识特定缓冲区的一位或两位十进制数?br />   可以使用非捕获元字符 '?:', '?=', or '?!' 来忽略对相关匚w的保存?

各种操作W的q算优先U?/h3>
  相同优先U的从左到右q行q算Q不同优先的运先高后低。各U操作符的优先从高C如下Q?br />
操作W?描述
\ 转义W?/td>
(), (?:), (?=), [] 圆括号和Ҏ?/td>
*, +, ?, {n}, {n,}, {n,m} 限定W?/td>
^, $, \anymetacharacter 位置和顺?/td>
| “或”操?/td>

全部W号解释


字符 描述
\
^ 匚w输入字符串的开始位|。如果设|了 RegExp 对象?Multiline 属性,^ 也匹?'\n' ?'\r' 之后的位|?/td>
$ 匚w输入字符串的l束位置。如果设|了RegExp 对象?Multiline 属性,$ 也匹?'\n' ?'\r' 之前的位|?/td>
* 匚w前面的子表达式零ơ或多次。例如,zo* 能匹?"z" 以及 "zoo"? {h于{0,}?/td>
+
?
{n} n 是一个非负整数。匹配确定的 n ơ。例如,'o{2}' 不能匚w "Bob" 中的 'o'Q但是能匚w "food" 中的两个 o?/td>
{n,} n 是一个非负整数。至匹配n ơ。例如,'o{2,}' 不能匚w "Bob" 中的 'o'Q但能匹?"foooood" 中的所?o?o{1,}' {h?'o+'?o{0,}' 则等价于 'o*'?/td>
{n,m} m ?n 均ؓ非负整数Q其中n <= m。最匹?n ơ且最多匹?m ơ。例如,"o{1,3}" 匹?"fooooood" 中的前三?o?o{0,1}' {h?'o?'。请注意在逗号和两个数之间不能有空根{?/td>
? ? 该字W紧跟在M一个其他限制符 (*, +, ?, {n}, {n,}, {n,m}) 后面Ӟ匚w模式是非贪婪的。非贪婪模式可能少的匹配所搜烦的字W串Q而默认的贪婪模式则尽可能多的匚w所搜烦的字W串。例如,对于字符? "oooo"Q?o+?' 匹配单?"o"Q?'o+' 匹配所?'o'?/td>
.
(pattern) 匚w pattern q获取这一匚w。所获取的匹配可以从产生?Matches 集合得到Q在VBScript 中?SubMatches 集合Q在JScript 中则使用 $0?9 属性。要匚w圆括号字W,请?'\(' ?'\)'?/td>
(?:pattern) ? ?pattern 但不获取匚wl果Q也是说这是一个非获取匚wQ不q行存储供以后用。这在?"? 字符 (|) 来组合一个模式的各个部分是很有用。例如, 'industr(?:y|ies) 是一个比 'industry|industries' 更简略的表达式?/td>
(?=pattern) ? 向预查,在Q何匹?pattern 的字W串开始处匚w查找字符丌Ӏ这是一个非获取匚wQ也是_该匹配不需要获取供以后使用。例如,'Windows (?=95|98|NT|2000)' 能匹?"Windows 2000" 中的 "Windows" Q但不能匚w "Windows 3.1" 中的 "Windows"。预查不消耗字W,也就是说Q在一个匹配发生后Q在最后一ơ匹配之后立卛_始下一ơ匹配的搜烦Q而不是从包含预查的字W之后开始?/td>
(?!pattern) ? 向预查,在Q何不匚w pattern 的字W串开始处匚w查找字符丌Ӏ这是一个非获取匚wQ也是_该匹配不需要获取供以后使用。例?Windows (?!95|98|NT|2000)' 能匹?"Windows 3.1" 中的 "Windows"Q但不能匚w "Windows 2000" 中的 "Windows"。预查不消耗字W,也就是说Q在一个匹配发生后Q在最后一ơ匹配之后立卛_始下一ơ匹配的搜烦Q而不是从包含预查的字W之后开?/td>
x|y 匚w x ?y。例如,'z|food' 能匹?"z" ?"food"?(z|f)ood' 则匹?"zood" ?"food"?/td>
[xyz]
[^xyz]
[a-z]
[^a-z]
\b
\B
\cx 匚w?x 指明的控制字W。例如, \cM 匚w一?Control-M 或回车符。x 的值必Mؓ A-Z ?a-z 之一。否则,?c 视ؓ一个原义的 'c' 字符?/td>
\d 匚w一个数字字W。等价于 [0-9]?/td>
\D 匚w一个非数字字符。等价于 [^0-9]?/td>
\f 匚w一个换늬。等价于 \x0c ?\cL?/td>
\n 匚w一个换行符。等价于 \x0a ?\cJ?/td>
\r 匚w一个回车符。等价于 \x0d ?\cM?/td>
\s 匚wMI白字符Q包括空根{制表符、换늬{等。等价于 [ \f\n\r\t\v]?/td>
\S 匚wM非空白字W。等价于 [^ \f\n\r\t\v]?/td>
\t 匚w一个制表符。等价于 \x09 ?\cI?/td>
\v 匚w一个垂直制表符。等价于 \x0b ?\cK?/td>
\w
\W
\xn 匚w nQ其?n 为十六进制{义倹{十六进制{义值必Mؓ定的两个数字长。例如,'\x41' 匚w "A"?\x041' 则等价于 '\x04' & "1"。正则表辑ּ中可以?ASCII ~码?
\num 匚w numQ其?num 是一个正整数。对所获取的匹配的引用。例如,'(.)\1' 匚w两个q箋的相同字W?/td>
\n 标识一个八q制转义值或一个向后引用。如?\n 之前臛_ n 个获取的子表辑ּQ则 n 为向后引用。否则,如果 n 为八q制数字 (0-7)Q则 n Z个八q制转义倹{?/td>
\nm ? 识一个八q制转义值或一个向后引用。如?\nm 之前臛_?nm 个获得子表达式,?nm 为向后引用。如?\nm 之前臛_?n 个获取,?n Z个后跟文?m 的向后引用。如果前面的条g都不满Q若 n ?m 均ؓ八进制数?(0-7)Q则 \nm 匹配八q制转义?nm?/td>
\nml 如果 n 为八q制数字 (0-3)Q且 m ?l 均ؓ八进制数?(0-7)Q则匚w八进制{义?nml?/td>
\un 匚w nQ其?n 是一个用四个十六q制数字表示?Unicode 字符。例如, \u00A9 匚w版权W号 (?)?/td>

部分例子


正则表达?/td>说明
/\b([a-z]+) \1\b/gi一个单词连l出现的位置
/(\w+):\/\/([^/:]+)(:\d*)?([^# ]*)/ 一个URL解析为协议、域、端口及相对路径
/^(?:Chapter|Section) [1-9][0-9]{0,1}$/定位章节的位|?/td>
/[-a-z]/A至z?6个字母再加一?受?/td>
/ter\b/可匹配chapterQ而不能terminal
/\Bapt/可匹配chapterQ而不能aptitude
/Windows(?=95 |98 |NT )/可匹配Windows95或Windows98或WindowsNT,当找C个匹配后Q从Windows后面开始进行下一ơ的索匹配?/td>



brent 2006-12-03 00:28 发表评论
]]> һþ֪ۺϾþ| ޾ƷWWWþþþþ| ˾þô߽ۺͼƬ| þһ99| avɫۺϾþavɫۺ | þþþAVרվ| þۺϾɫۺŷȥ| þۺϳDž| þþþùһëƬ| Ʒþþþþþö| þþþþþþþþþþþ| þþƷ99Ӱ| ˼˼þþƷ| ƷѾþþþþþþ| þۺ³³| ƷѾþþþþþþ| þþavҰһ| ŷþۺ | ҹƵþþþһ| þþƷˬӰ| Ʒþþ21p| þþƷһ| þþþþAVר| 91޹˾þþƷ| 츾޾þĻ| ùƷӰ˾þ| þþþƷѹĻ| þþƷ| ޾Ʒþþþ| þþƷ99Ʒ | þӰԺۺϾƷ| AVҰ¾þ| þ޹ƷAVϼ | ˾Ʒþ| ˾þþƷһ | þþþþþ| ȫɫƴɫƬѾþþ| Ʒ99þþþ | Ʒþþþþù˽| ľƷþþþþò| ޹Ʒþþò|