AndEngine源码 下载
jdk1.6 下载
1、下载、解压后放在磁盘上,如下图
2、导入工程
选择点击Next。出现如下图
Copy projects into workspace 将项目拷贝到工作区
点击finish。则完成项目的导入。出现入下图。
这里就要注意啦,导入的工程可能在项目上有个红色叉或则红色叹号。出现这种情况的有两张原因【如果不是代码错误的话】
a、 project.properties文件的target=android-15版本错误android-15是指你开发环节没有android版本为15的开发包。我开发环境没有版本15的,所以就报错。修改就可以了,查看自己的版本,入下图【AndEngine的android版本最好17以上】
图显示的只有android18这个版本
b、 第二种情况就是jdk版本过低,AndEngine要1.6以上的jdk
3、正常的项目如图:
执行repo sync之后,停住了,如下红色错误信息:
error: frameworks/base/: branch 0730 is published (but not merged) and is now 2266 commits behind
什么意思呢?
解决办法,执行:
repo rebase
[姝e垯琛ㄨ揪寮廬鏂囨湰妗嗚緭鍏ュ唴瀹规帶鍒?br>鏁存暟鎴栬€呭皬鏁帮細^[0-9]+\.{0,1}[0-9]{0,2}$
鍙兘杈撳叆鏁板瓧锛?^[0-9]*$"銆?br>鍙兘杈撳叆n浣嶇殑鏁板瓧锛?^\d{n}$"銆?br>鍙兘杈撳叆鑷冲皯n浣嶇殑鏁板瓧锛?^\d{n,}$"銆?br>鍙兘杈撳叆m~n浣嶇殑鏁板瓧锛氥€?^\d{m,n}$"
鍙兘杈撳叆闆跺拰闈為浂寮€澶寸殑鏁板瓧锛?^(0|[1-9][0-9]*)$"銆?br>鍙兘杈撳叆鏈変袱浣嶅皬鏁扮殑姝e疄鏁帮細"^[0-9]+(.[0-9]{2})?$"銆?br>鍙兘杈撳叆鏈?~3浣嶅皬鏁扮殑姝e疄鏁帮細"^[0-9]+(.[0-9]{1,3})?$"銆?br>鍙兘杈撳叆闈為浂鐨勬鏁存暟锛?^\+?[1-9][0-9]*$"銆?br>鍙兘杈撳叆闈為浂鐨勮礋鏁存暟锛?^\-[1-9][]0-9"*$銆?br>鍙兘杈撳叆闀垮害涓?鐨勫瓧绗︼細"^.{3}$"銆?br>鍙兘杈撳叆鐢?6涓嫳鏂囧瓧姣嶇粍鎴愮殑瀛楃涓诧細"^[A-Za-z]+$"銆?br>鍙兘杈撳叆鐢?6涓ぇ鍐欒嫳鏂囧瓧姣嶇粍鎴愮殑瀛楃涓诧細"^[A-Z]+$"銆?br>鍙兘杈撳叆鐢?6涓皬鍐欒嫳鏂囧瓧姣嶇粍鎴愮殑瀛楃涓诧細"^[a-z]+$"銆?br>鍙兘杈撳叆鐢辨暟瀛楀拰26涓嫳鏂囧瓧姣嶇粍鎴愮殑瀛楃涓诧細"^[A-Za-z0-9]+$"銆?br>鍙兘杈撳叆鐢辨暟瀛椼€?6涓嫳鏂囧瓧姣嶆垨鑰呬笅鍒掔嚎缁勬垚鐨勫瓧绗︿覆锛?^\w+$"銆?br>楠岃瘉鐢ㄦ埛瀵嗙爜锛?^[a-zA-Z]\w{5,17}$"姝g‘鏍煎紡涓猴細浠ュ瓧姣嶅紑澶达紝闀垮害鍦?~18涔嬮棿锛屽彧鑳藉寘鍚瓧绗︺€佹暟瀛楀拰涓嬪垝绾裤€?br>楠岃瘉鏄惁鍚湁^%&',;=?$\"绛夊瓧绗︼細"[^%&',;=?$\x22]+"銆?br>鍙兘杈撳叆姹夊瓧锛?^[\u4e00-\u9fa5]{0,}$"
楠岃瘉Email鍦板潃锛?^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$"銆?br>楠岃瘉InternetURL锛?^http://([\w-]+\.)+[\w-]+(/[\w-./?%&=]*)?$"銆?br>楠岃瘉鐢佃瘽鍙风爜锛?^(\(\d{3,4}-)|\d{3.4}-)?\d{7,8}$"姝g‘鏍煎紡涓猴細"XXX-XXXXXXX"銆?XXXX-XXXXXXXX"銆?XXX-XXXXXXX"銆?XXX-XXXXXXXX"銆?XXXXXXX"鍜?XXXXXXXX"銆?br>楠岃瘉韬唤璇佸彿锛?5浣嶆垨18浣嶆暟瀛楋級锛?^\d{15}|\d{18}$"銆?br>楠岃瘉涓€骞寸殑12涓湀锛?^(0?[1-9]|1[0-2])$"姝g‘鏍煎紡涓猴細"01"锝?09"鍜?1"锝?12"銆?br>楠岃瘉涓€涓湀鐨?1澶╋細"^((0?[1-9])|((1|2)[0-9])|30|31)$"姝g‘鏍煎紡涓猴紱"01"锝?09"鍜?1"锝?31"銆?br>鍖归厤涓枃瀛楃鐨勬鍒欒〃杈惧紡锛?[\u4e00-\u9fa5]
鍖归厤鍙屽瓧鑺傚瓧绗?鍖呮嫭姹夊瓧鍦ㄥ唴)锛歔^\x00-\xff]
搴旂敤锛氳绠楀瓧绗︿覆鐨勯暱搴︼紙涓€涓弻瀛楄妭瀛楃闀垮害璁?锛孉SCII瀛楃璁?锛?br>String.prototype.len=function(){return this.replace(/[^\x00-\xff]/g,"aa").length;}
鍖归厤绌鸿鐨勬鍒欒〃杈惧紡锛歕n[\s| ]*\r
鍖归厤html鏍囩鐨勬鍒欒〃杈惧紡锛?lt;(.*)>(.*)<\/(.*)>|<(.*)\/>
鍖归厤棣栧熬绌烘牸鐨勬鍒欒〃杈惧紡锛?^\s*)|(\s*$)
搴旂敤锛歫avascript涓病鏈夊儚vbscript閭f牱鐨則rim鍑芥暟锛屾垜浠氨鍙互鍒╃敤杩欎釜琛ㄨ揪寮忔潵瀹炵幇锛屽涓嬶細
String.prototype.trim = function()
{
return this.replace(/(^\s*)|(\s*$)/g, "");
}
鍒╃敤姝e垯琛ㄨ揪寮忓垎瑙e拰杞崲IP鍦板潃锛?br>涓嬮潰鏄埄鐢ㄦ鍒欒〃杈惧紡鍖归厤IP鍦板潃锛屽苟灏咺P鍦板潃杞崲鎴愬搴旀暟鍊肩殑Javascript绋嬪簭锛?br>function IP2V(ip)
{
re=/(\d+)\.(\d+)\.(\d+)\.(\d+)/g //鍖归厤IP鍦板潃鐨勬鍒欒〃杈惧紡
if(re.test(ip))
{
return RegExp.$1*Math.pow(255,3))+RegExp.$2*Math.pow(255,2))+RegExp.$3*255+RegExp.$4*1
}
else
{
throw new Error("Not a valid IP address!")
}
}
涓嶈繃涓婇潰鐨勭▼搴忓鏋滀笉鐢ㄦ鍒欒〃杈惧紡锛岃€岀洿鎺ョ敤split鍑芥暟鏉ュ垎瑙e彲鑳芥洿绠€鍗曪紝绋嬪簭濡備笅锛?br>var ip="10.100.20.168"
ip=ip.split(".")
alert("IP鍊兼槸锛?+(ip[0]*255*255*255+ip[1]*255*255+ip[2]*255+ip[3]*1))
鍖归厤Email鍦板潃鐨勬鍒欒〃杈惧紡锛歕w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
鍖归厤缃戝潃URL鐨勬鍒欒〃杈惧紡锛?a href="http://(%5B/w-%5D+/.)+%5B/w-%5D+(/%5B/w">http://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?
鍒╃敤姝e垯琛ㄨ揪寮忛檺鍒剁綉椤佃〃鍗曢噷鐨勬枃鏈杈撳叆鍐呭锛?br>鐢ㄦ鍒欒〃杈惧紡闄愬埗鍙兘杈撳叆涓枃锛歰nkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\u4E00-\u9FA5]/g,''))"
鐢ㄦ鍒欒〃杈惧紡闄愬埗鍙兘杈撳叆鍏ㄨ瀛楃锛?onkeyup="value=value.replace(/[^\uFF00-\uFFFF]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\uFF00-\uFFFF]/g,''))"
鐢ㄦ鍒欒〃杈惧紡闄愬埗鍙兘杈撳叆鏁板瓧锛歰nkeyup="value=value.replace(/[^\d]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"
鐢ㄦ鍒欒〃杈惧紡闄愬埗鍙兘杈撳叆鏁板瓧鍜岃嫳鏂囷細onkeyup="value=value.replace(/[\W]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"
<input onkeyup="value=value.replace(/[^\u4E00-\u9FA5\w]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\u4E00-\u9FA5\w]/g,''))" value="鍏佽涓嬪垝绾?鏁板瓧瀛楁瘝鍜屾眽瀛?>
<script language="javascript">
if (document.layers)//瑙﹀彂閿洏浜嬩欢
document.captureEvents(Event.KEYPRESS)
function xz(thsv,nob){
if(nob=="2"){
window.clipboardData.setData("text","")
alert("閬垮厤闈炴硶瀛楃杈撳叆,璇峰嬁澶嶅埗瀛楃");
return false;
}
if (event.keyCode!=8 && event.keyCode!=16 && event.keyCode!=37 && event.keyCode!=38 && event.keyCode!=39 && event.keyCode!=40){
thsvv=thsv.value;//杈撳叆鐨勫€?br>thsvs=thsvv.substring(thsvv.length-1);//杈撳叆鐨勬渶鍚庝竴涓瓧绗?br>//thsvss=thsvv.substring(0,thsvv.length-1);//鍘绘帀鏈€鍚庝竴涓敊璇瓧绗?br>if (!thsvs.replace(/[^\u4E00-\u9FA5\w]/g,'') || event.keyCode==189){//姝e垯闄ゅ幓绗﹀彿鍜屼笅鍒掔嚎 key
thsv.value='璇峰嬁杈撳叆闈炴硶绗﹀彿 ['+thsvs+']';
alert('璇峰嬁杈撳叆闈炴硶绗﹀彿 ['+thsvs+']');
thsv.value="";
return false;
}
}
}
</script>
<input onkeyup="xz(this,1)" onPaste="xz(this,2)" value="">鍏佽鏁板瓧瀛楁瘝鍜屾眽瀛?br><script language="javascript">
<!--
function MaxLength(field,maxlimit){
var j = field.value.replace(/[^\x00-\xff]/g,"**").length;
//alert(j);
var tempString=field.value;
var tt="";
if(j > maxlimit){
for(var i=0;i<maxlimit;i++){
if(tt.replace(/[^\x00-\xff]/g,"**").length < maxlimit)
tt = tempString.substr(0,i+1);
else
break;
}
if(tt.replace(/[^\x00-\xff]/g,"**").length > maxlimit)
tt=tt.substr(0,tt.length-1);
field.value = tt;
}else{
;
}
}
</script>
鍗曡鏂囨湰妗嗘帶鍒?lt;br />
<INPUT type="text" id="Text1" name="Text1" onpropertychange="MaxLength(this, 5)"><br />
澶氳鏂囨湰妗嗘帶鍒?<br />
<TEXTAREA rows="14"
cols="39" id="Textarea1" name="Textarea1" onpropertychange="MaxLength(this, 15)"></TEXTAREA><br />
鎺у埗琛ㄥ崟鍐呭鍙兘杈撳叆鏁板瓧,涓枃....
<script>
function test()聽
{
if(document.a.b.value.length>50)
{
alert("涓嶈兘瓒呰繃50涓瓧绗︼紒");
document.a.b.focus();
return false;
}
}
</script>
<form name=a onsubmit="return test()">
<textarea name="b" cols="40" wrap="VIRTUAL" rows="6"></textarea>
<input type="submit" name="Submit" value="check">
</form>
鍙兘鏄眽瀛?br><input onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,'')">
鍙兘鏄嫳鏂囧瓧绗?br><script language=javascript>
function onlyEng()
{
if(!(event.keyCode>=65&&event.keyCode<=90))
聽聽聽 event.returnValue=false;
}
</script>
<input onkeydown="onlyEng();">
<input name="coname" type="text" size="50" maxlength="35" onkeyup="value=value.replace(/[\W]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))">
鍙兘鏄暟瀛?br><script language=javascript>
function onlyNum()
{
if(!((event.keyCode>=48&&event.keyCode<=57)||(event.keyCode>=96&&event.keyCode<=105)))
//鑰冭檻灏忛敭鐩樹笂鐨勬暟瀛楅敭
聽聽聽 event.returnValue=false;
}
</script>
<input onkeydown="onlyNum();">
鍙兘鏄嫳鏂囧瓧绗﹀拰鏁板瓧
<input onkeyup="value=value.replace(/[\W]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))">
楠岃瘉涓篹mail鏍煎紡
<SCRIPT LANGUAGE=Javascript RUNAT=Server>
function isEmail(strEmail) {
if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
return true;
else
alert("oh");
}
</SCRIPT>
<input type=text onblur=isEmail(this.value)>
灞忚斀鍏抽敭瀛?sex , fuck) - 宸蹭慨鏀?br><script language="JavaScript1.2">
function test() {
if((a.b.value.indexOf ("sex") == 0)||(a.b.value.indexOf ("fuck") == 0)){
聽聽聽 alert("浜旇鍥涚編涓夌儹鐖?);
聽聽聽 a.b.focus();
聽聽聽 return false;}
}
</script>
<form name=a onsubmit="return test()">
<input type=text name=b>
<input type="submit" name="Submit" value="check">
</form>
闄愬埗鏂囨湰妗嗛噷鍙兘杈撳叆鏁板瓧
<input onkeyup="if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,'');"onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))">
<PIXTEL_MMI_EBOOK_2005>2聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 </PIXTEL_MMI_EBOOK_2005>
JAVA姝e垯琛ㄨ揪寮忚娉曪紙杞級
姝e垯琛ㄨ揪寮忚娉?/p>
姝e垯琛ㄨ揪寮忔槸涓€绉嶆枃鏈ā寮忥紝鍖呮嫭鏅€氬瓧绗︼紙渚嬪锛宎 鍒?z 涔嬮棿鐨勫瓧姣嶏級鍜岀壒娈婂瓧绗︼紙绉颁负鈥滃厓瀛楃鈥濓級銆傛ā寮忔弿杩板湪鎼滅储鏂囨湰鏃惰鍖归厤鐨勪竴涓垨澶氫釜瀛楃涓层€?/p>
姝e垯琛ㄨ揪寮忕ず渚?/p>
琛ㄨ揪寮?鍖归厤
/^\s*$/
鍖归厤绌鸿銆?/p>
/\d{2}-\d{5}/
楠岃瘉鐢变袱浣嶆暟瀛椼€佷竴涓繛瀛楃鍐嶅姞 5 浣嶆暟瀛楃粍鎴愮殑 ID 鍙枫€?/p>
/<\s*(\S+)(\s[^>]*)?>[\s\S]*<\s*\/\1\s*>/
鍖归厤 HTML 鏍囪銆?/p>
涓嬭〃鍖呭惈浜嗗厓瀛楃鐨勫畬鏁村垪琛ㄤ互鍙婂畠浠湪姝e垯琛ㄨ揪寮忎笂涓嬫枃涓殑琛屼负锛?/p>
瀛楃 璇存槑
\
灏嗕笅涓€瀛楃鏍囪涓虹壒娈婂瓧绗︺€佹枃鏈€佸弽鍚戝紩鐢ㄦ垨鍏繘鍒惰浆涔夌銆備緥濡傦紝鈥渘鈥濆尮閰嶅瓧绗︹€渘鈥濄€傗€淺n鈥濆尮閰嶆崲琛岀銆傚簭鍒椻€淺\鈥濆尮閰嶁€淺鈥濓紝鈥淺(鈥濆尮閰嶁€?鈥濄€?/p>
^
鍖归厤杈撳叆瀛楃涓插紑濮嬬殑浣嶇疆銆傚鏋滆缃簡 RegExp 瀵硅薄鐨?Multiline 灞炴€э紝^ 杩樹細涓庘€淺n鈥濇垨鈥淺r鈥濅箣鍚庣殑浣嶇疆鍖归厤銆?/p>
$
鍖归厤杈撳叆瀛楃涓茬粨灏剧殑浣嶇疆銆傚鏋滆缃簡 RegExp 瀵硅薄鐨?Multiline 灞炴€э紝$ 杩樹細涓庘€淺n鈥濇垨鈥淺r鈥濅箣鍓嶇殑浣嶇疆鍖归厤銆?/p>
*
闆舵鎴栧娆″尮閰嶅墠闈㈢殑瀛楃鎴栧瓙琛ㄨ揪寮忋€備緥濡傦紝zo* 鍖归厤鈥渮鈥濆拰鈥渮oo鈥濄€? 绛夋晥浜?{0,}銆?/p>
+
涓€娆℃垨澶氭鍖归厤鍓嶉潰鐨勫瓧绗︽垨瀛愯〃杈惧紡銆備緥濡傦紝鈥渮o+鈥濅笌鈥渮o鈥濆拰鈥渮oo鈥濆尮閰嶏紝浣嗕笌鈥渮鈥濅笉鍖归厤銆? 绛夋晥浜?{1,}銆?/p>
?
闆舵鎴栦竴娆″尮閰嶅墠闈㈢殑瀛楃鎴栧瓙琛ㄨ揪寮忋€備緥濡傦紝鈥渄o(es)?鈥濆尮閰嶁€渄o鈥濇垨鈥渄oes鈥濅腑鐨勨€渄o鈥濄€? 绛夋晥浜?{0,1}銆?/p>
{n}
n 鏄潪璐熸暣鏁般€傛濂藉尮閰?n 娆°€備緥濡傦紝鈥渙{2}鈥濅笌鈥淏ob鈥濅腑鐨勨€渙鈥濅笉鍖归厤锛屼絾涓庘€渇ood鈥濅腑鐨勪袱涓€渙鈥濆尮閰嶃€?/p>
{n,}
n 鏄潪璐熸暣鏁般€傝嚦灏戝尮閰?n 娆°€備緥濡傦紝鈥渙{2,}鈥濅笉鍖归厤鈥淏ob鈥濅腑鐨勨€渙鈥濓紝鑰屽尮閰嶁€渇oooood鈥濅腑鐨勬墍鏈?o銆傗€渙{1,}鈥濈瓑鏁堜簬鈥渙+鈥濄€傗€渙{0,}鈥濈瓑鏁堜簬鈥渙*鈥濄€?/p>
{n,m}
M 鍜?n 鏄潪璐熸暣鏁帮紝鍏朵腑 n <= m銆傚尮閰嶈嚦灏?n 娆★紝鑷冲 m 娆°€備緥濡傦紝鈥渙{1,3}鈥濆尮閰嶁€渇ooooood鈥濅腑鐨勫ご涓変釜 o銆?o{0,1}' 绛夋晥浜?'o?'銆傛敞鎰忥細鎮ㄤ笉鑳藉皢绌烘牸鎻掑叆閫楀彿鍜屾暟瀛椾箣闂淬€?/p>
?
褰撴瀛楃绱ч殢浠讳綍鍏朵粬闄愬畾绗︼紙*銆?銆?銆亄n}銆亄n,}銆亄n,m}锛変箣鍚庢椂锛屽尮閰嶆ā寮忔槸鈥滈潪璐績鐨勨€濄€傗€滈潪璐績鐨勨€濇ā寮忓尮閰嶆悳绱㈠埌鐨勩€佸敖鍙兘鐭殑瀛楃涓诧紝鑰岄粯璁ょ殑鈥滆椽蹇冪殑鈥濇ā寮忓尮閰嶆悳绱㈠埌鐨勩€佸敖鍙兘闀跨殑瀛楃涓层€備緥濡傦紝鍦ㄥ瓧绗︿覆鈥渙ooo鈥濅腑锛屸€渙+?鈥濆彧鍖归厤鍗曚釜鈥渙鈥濓紝鑰屸€渙+鈥濆尮閰嶆墍鏈夆€渙鈥濄€?/p>
.
鍖归厤闄も€淺n鈥濅箣澶栫殑浠讳綍鍗曚釜瀛楃銆傝嫢瑕佸尮閰嶅寘鎷€淺n鈥濆湪鍐呯殑浠绘剰瀛楃锛岃浣跨敤璇稿鈥淸\s\S]鈥濅箣绫荤殑妯″紡銆?/p>
(pattern)
鍖归厤 pattern 骞舵崟鑾疯鍖归厤鐨勫瓙琛ㄨ揪寮忋€傚彲浠ヤ娇鐢?$0鈥?9 灞炴€т粠缁撴灉鈥滃尮閰嶁€濋泦鍚堜腑妫€绱㈡崟鑾风殑鍖归厤銆傝嫢瑕佸尮閰嶆嫭鍙峰瓧绗?( )锛岃浣跨敤鈥淺(鈥濇垨鑰呪€淺)鈥濄€?/p>
(?:pattern)
鍖归厤 pattern 浣嗕笉鎹曡幏璇ュ尮閰嶇殑瀛愯〃杈惧紡锛屽嵆瀹冩槸涓€涓潪鎹曡幏鍖归厤锛屼笉瀛樺偍渚涗互鍚庝娇鐢ㄧ殑鍖归厤銆傝繖瀵逛簬鐢ㄢ€渙r鈥濆瓧绗?(|) 缁勫悎妯″紡閮ㄤ欢鐨勬儏鍐靛緢鏈夌敤銆備緥濡傦紝'industr(?:y|ies) 鏄瘮 'industry|industries' 鏇寸粡娴庣殑琛ㄨ揪寮忋€?/p>
(?=pattern)
鎵ц姝e悜棰勬祴鍏堣鎼滅储鐨勫瓙琛ㄨ揪寮忥紝璇ヨ〃杈惧紡鍖归厤澶勪簬鍖归厤 pattern 鐨勫瓧绗︿覆鐨勮捣濮嬬偣鐨勫瓧绗︿覆銆傚畠鏄竴涓潪鎹曡幏鍖归厤锛屽嵆涓嶈兘鎹曡幏渚涗互鍚庝娇鐢ㄧ殑鍖归厤銆備緥濡傦紝'Windows (?=95|98|NT|2000)' 鍖归厤鈥淲indows 2000鈥濅腑鐨勨€淲indows鈥濓紝浣嗕笉鍖归厤鈥淲indows 3.1鈥濅腑鐨勨€淲indows鈥濄€傞娴嬪厛琛屼笉鍗犵敤瀛楃锛屽嵆鍙戠敓鍖归厤鍚庯紝涓嬩竴鍖归厤鐨勬悳绱㈢揣闅忎笂涓€鍖归厤涔嬪悗锛岃€屼笉鏄湪缁勬垚棰勬祴鍏堣鐨勫瓧绗﹀悗銆?/p>
(?!pattern)
鎵ц鍙嶅悜棰勬祴鍏堣鎼滅储鐨勫瓙琛ㄨ揪寮忥紝璇ヨ〃杈惧紡鍖归厤涓嶅浜庡尮閰?pattern 鐨勫瓧绗︿覆鐨勮捣濮嬬偣鐨勬悳绱㈠瓧绗︿覆銆傚畠鏄竴涓潪鎹曡幏鍖归厤锛屽嵆涓嶈兘鎹曡幏渚涗互鍚庝娇鐢ㄧ殑鍖归厤銆備緥濡傦紝'Windows (?!95|98|NT|2000)' 鍖归厤鈥淲indows 3.1鈥濅腑鐨?鈥淲indows鈥濓紝浣嗕笉鍖归厤鈥淲indows 2000鈥濅腑鐨勨€淲indows鈥濄€傞娴嬪厛琛屼笉鍗犵敤瀛楃锛屽嵆鍙戠敓鍖归厤鍚庯紝涓嬩竴鍖归厤鐨勬悳绱㈢揣闅忎笂涓€鍖归厤涔嬪悗锛岃€屼笉鏄湪缁勬垚棰勬祴鍏堣鐨勫瓧绗﹀悗銆?/p>
x|y
鍖归厤 x 鎴?y銆備緥濡傦紝'z|food' 鍖归厤鈥渮鈥濇垨鈥渇ood鈥濄€?(z|f)ood' 鍖归厤鈥渮ood鈥濇垨鈥渇ood鈥濄€?/p>
[xyz]
瀛楃闆嗐€傚尮閰嶅寘鍚殑浠讳竴瀛楃銆備緥濡傦紝鈥淸abc]鈥濆尮閰嶁€減lain鈥濅腑鐨勨€渁鈥濄€?/p>
[^xyz]
鍙嶅悜瀛楃闆嗐€傚尮閰嶆湭鍖呭惈鐨勪换浣曞瓧绗︺€備緥濡傦紝鈥淸^abc]鈥濆尮閰嶁€減lain鈥濅腑鐨勨€減鈥濄€?/p>
[a-z]
瀛楃鑼冨洿銆傚尮閰嶆寚瀹氳寖鍥村唴鐨勪换浣曞瓧绗︺€備緥濡傦紝鈥淸a-z]鈥濆尮閰嶁€渁鈥濆埌鈥渮鈥濊寖鍥村唴鐨勪换浣曞皬鍐欏瓧姣嶃€?/p>
[^a-z]
鍙嶅悜鑼冨洿瀛楃銆傚尮閰嶄笉鍦ㄦ寚瀹氱殑鑼冨洿鍐呯殑浠讳綍瀛楃銆備緥濡傦紝鈥淸^a-z]鈥濆尮閰嶄换浣曚笉鍦ㄢ€渁鈥濆埌鈥渮鈥濊寖鍥村唴鐨勪换浣曞瓧绗︺€?/p>
\b
鍖归厤涓€涓瓧杈圭晫锛屽嵆瀛椾笌绌烘牸闂寸殑浣嶇疆銆備緥濡傦紝鈥渆r\b鈥濆尮閰嶁€渘ever鈥濅腑鐨勨€渆r鈥濓紝浣嗕笉鍖归厤鈥渧erb鈥濅腑鐨勨€渆r鈥濄€?/p>
\B
闈炲瓧杈圭晫鍖归厤銆傗€渆r\B鈥濆尮閰嶁€渧erb鈥濅腑鐨勨€渆r鈥濓紝浣嗕笉鍖归厤鈥渘ever鈥濅腑鐨勨€渆r鈥濄€?/p>
\cx
鍖归厤 x 鎸囩ず鐨勬帶鍒跺瓧绗︺€備緥濡傦紝\cM 鍖归厤 Control-M 鎴栧洖杞︾銆倄 鐨勫€煎繀椤诲湪 A-Z 鎴?a-z 涔嬮棿銆傚鏋滀笉鏄繖鏍凤紝鍒欏亣瀹?c 灏辨槸鈥渃鈥濆瓧绗︽湰韬€?/p>
\d
鏁板瓧瀛楃鍖归厤銆傜瓑鏁堜簬 [0-9]銆?/p>
\D
闈炴暟瀛楀瓧绗﹀尮閰嶃€傜瓑鏁堜簬 [^0-9]銆?/p>
\f
鎹㈤〉绗﹀尮閰嶃€傜瓑鏁堜簬 \x0c 鍜?\cL銆?/p>
\n
鎹㈣绗﹀尮閰嶃€傜瓑鏁堜簬 \x0a 鍜?\cJ銆?/p>
\r
鍖归厤涓€涓洖杞︾銆傜瓑鏁堜簬 \x0d 鍜?\cM銆?/p>
\s
鍖归厤浠讳綍绌虹櫧瀛楃锛屽寘鎷┖鏍笺€佸埗琛ㄧ銆佹崲椤电绛夈€備笌 [ \f\n\r\t\v] 绛夋晥銆?/p>
\S
鍖归厤浠讳綍闈炵┖鐧藉瓧绗︺€備笌 [^ \f\n\r\t\v] 绛夋晥銆?/p>
\t
鍒惰〃绗﹀尮閰嶃€備笌 \x09 鍜?\cI 绛夋晥銆?/p>
\v
鍨傜洿鍒惰〃绗﹀尮閰嶃€備笌 \x0b 鍜?\cK 绛夋晥銆?/p>
\w
鍖归厤浠讳綍瀛楃被瀛楃锛屽寘鎷笅鍒掔嚎銆備笌鈥淸A-Za-z0-9_]鈥濈瓑鏁堛€?/p>
\W
涓庝换浣曢潪鍗曡瘝瀛楃鍖归厤銆備笌鈥淸^A-Za-z0-9_]鈥濈瓑鏁堛€?/p>
\xn
鍖归厤 n锛屾澶勭殑 n 鏄竴涓崄鍏繘鍒惰浆涔夌爜銆傚崄鍏繘鍒惰浆涔夌爜蹇呴』姝eソ鏄袱浣嶆暟闀裤€備緥濡傦紝鈥淺x41鈥濆尮閰嶁€淎鈥濄€傗€淺x041鈥濅笌鈥淺x04鈥?amp;鈥?鈥濈瓑鏁堛€傚厑璁稿湪姝e垯琛ㄨ揪寮忎腑浣跨敤 ASCII 浠g爜銆?/p>
\num
鍖归厤 num锛屾澶勭殑 num 鏄竴涓鏁存暟銆傚埌鎹曡幏鍖归厤鐨勫弽鍚戝紩鐢ㄣ€備緥濡傦紝鈥?.)\1鈥濆尮閰嶄袱涓繛缁殑鐩稿悓瀛楃銆?/p>
\n
鏍囪瘑涓€涓叓杩涘埗杞箟鐮佹垨鍙嶅悜寮曠敤銆傚鏋?\n 鍓嶉潰鑷冲皯鏈?n 涓崟鑾峰瓙琛ㄨ揪寮忥紝閭d箞 n 鏄弽鍚戝紩鐢ㄣ€傚惁鍒欙紝濡傛灉 n 鏄叓杩涘埗鏁?(0-7)锛岄偅涔?n 鏄叓杩涘埗杞箟鐮併€?/p>
\nm
鏍囪瘑涓€涓叓杩涘埗杞箟鐮佹垨鍙嶅悜寮曠敤銆傚鏋?\nm 鍓嶉潰鑷冲皯鏈?nm 涓崟鑾峰瓙琛ㄨ揪寮忥紝閭d箞 nm 鏄弽鍚戝紩鐢ㄣ€傚鏋?\nm 鍓嶉潰鑷冲皯鏈?n 涓崟鑾凤紝鍒?n 鏄弽鍚戝紩鐢紝鍚庨潰璺熸湁瀛楃 m銆傚鏋滀袱绉嶅墠闈㈢殑鎯呭喌閮戒笉瀛樺湪锛屽垯 \nm 鍖归厤鍏繘鍒跺€?nm锛屽叾涓?n 鍜?m 鏄叓杩涘埗鏁板瓧 (0-7)銆?/p>
\nml
褰?n 鏄叓杩涘埗鏁?(0-3)锛宮 鍜?l 鏄叓杩涘埗鏁?(0-7) 鏃讹紝鍖归厤鍏繘鍒惰浆涔夌爜 nml銆?/p>
\un
鍖归厤 n锛屽叾涓?n 鏄互鍥涗綅鍗佸叚杩涘埗鏁拌〃绀虹殑 Unicode 瀛楃銆備緥濡傦紝\u00A9 鍖归厤鐗堟潈绗﹀彿 (?)銆?/p>
鏉ヨ嚜:http://www.cnblogs.com/elleniou/archive/2012/07/31/2617312.html#2740161