当前位置:  编程技术>移动开发
本页文章导读:
    ▪娣卞叆鍏ラ棬姝e垯琛ㄨ揪寮忥紙java锛? 一 - 鍏ラ棬鍩虹        娣卞叆鍏ラ棬姝e垯琛ㄨ揪寮忥紙java锛?- 1 - 鍏ラ棬鍩虹 1.鍏冨瓧绗?/span> 聽 寰堝浜哄姝e垯琛ㄨ揪寮忕殑鍗拌薄灏辨槸涔辩爜銆傘€傝璁稿澶氱殑绗﹀彿缁勫悎鍦ㄤ竴璧凤紝.........
    ▪ 惯用的getResources()系列        常用的getResources()系列   以例子形式说明如何提取资源文件设置view或sting: private Context ctx; TextView mText = (TextView)findViewById(R.id.text); ImageView mImage = (ImageView)findViewById(R.id.image); TextView[] mTextVie.........
    ▪ listView中editview焦点有关问题       listView中editview焦点问题 http://stackoverflow.com/questions/2679948/focusable-edittext-inside-listview/2680077#2680077 ......

[1]娣卞叆鍏ラ棬姝e垯琛ㄨ揪寮忥紙java锛? 一 - 鍏ラ棬鍩虹
    来源: 互联网  发布时间: 2014-02-18
娣卞叆鍏ラ棬姝e垯琛ㄨ揪寮忥紙java锛?- 1 - 鍏ラ棬鍩虹

1.鍏冨瓧绗?/span>

寰堝浜哄姝e垯琛ㄨ揪寮忕殑鍗拌薄灏辨槸涔辩爜銆傘€傝璁稿澶氱殑绗﹀彿缁勫悎鍦ㄤ竴璧凤紝鍋惰鍗曡瘝锛屾鍒欑‘瀹炴槸杩欐牱鐨勶紝鎵€浠ヤ笅闈㈡垜浠鐪嬬湅杩欎簺绗﹀彿閮芥槸浠€涔堟剰鎬?/p>

鏈変簺绗﹀彿涓嶆槸澶у鐪嬪埌鐨勫瓧闈笂鐨勬剰鎬濓細姣斿鈥?鈥濄€佲€?鈥濄€佲€?鈥?/span> 鈥︹€?/p>

杩欎簺绗﹀彿灏辩О涔嬩负鍏冨瓧绗?/p>

寰堥仐鎲撅紝杩欎簺瀛楃鐨勬剰涔夊繀椤荤墷璁?/p>

娉ㄦ剰锛氭湰鏂囩殑鎵€鏈夌孩鑹插姞绮椾腑鏂囧紩鍙峰唴鐨勫唴瀹瑰潎涓烘鍒欒〃杈惧紡锛岃€屼笉鏄竴鑸殑瀛楃鍜岀鍙?/span>

涓嬮潰鎴戜滑閫愪竴璇存槑

鈥淺鈥?/span> 锛氳浆涔夌鍙凤紝鍦ㄥ瓧绗︾粍鍐呬緷鐒舵槸鍏冨瓧绗︺€?/p>

鍦ㄦ鏌ヤ竴琛屾枃鏈椂

鈥淾鈥?/span> 锛氳劚瀛楃锛氳〃绀轰竴琛岀殑寮€濮?/p>

鈥?鈥?/span> 锛氱編鍏冪鍙凤細琛ㄧず涓€琛岀殑缁撴潫

瀛楃缁?/p>

鈥淸]鈥?/span> 锛氫竴瀵逛腑鎷彿锛岄噷闈㈠彲浠ユ坊鍔犱换浣曞唴瀹癸紝姣斿[hate]锛屾嫭鍙烽噷闈㈢殑鍐呭鏄垨鑰呯殑鍏崇郴锛?strong>杩欎釜姝e垯鐨勬剰涔夋槸锛氭垜鎯冲尮閰嶄竴涓瓧绗︼紝杩欎釜瀛楃鍙互鏄痟锛屽彲浠ユ槸a锛屼篃鍙互鏄痶鎴杄銆?/span>

璁颁綇锛氬瓧绗︾粍鏈€缁堝彧浼氬尮閰嶄竴涓瓧绗︺€?/span> 鍗充娇浣犵殑鐩爣瀛楃涓叉槸hate锛岄偅涔堜竴娆″尮閰嶆垚鍔熺殑缁撴灉涔熷彧鏄涓€涓瓧姣峢锛屽苟涓嶆槸鏁翠釜鍗曡瘝锛屽鏋滄垜灏辨兂鍖归厤hate杩欎釜鍗曡瘝鎬庝箞鍔烇紵寰堝鏄擄紝姝e垯鍐呭涓衡€渉ate鈥濓紝鍦ㄥ瓧绗︾粍澶栭潰鐨勫瓧绗︾殑鍏崇郴鏄€滃拰锛屽苟涓斺€濈殑鎰忔€濄€?/p>

娉ㄦ剰锛氬瓧绗︾粍鍐呯殑鍏冨瓧绗﹀拰瀛楃缁勫鐨勫厓瀛楃骞朵笉涓€鏍凤紝鍗充娇瀛楃涓€鏍凤紝琛ㄧず鐨勬剰涔変篃鏈繀鐩稿悓 锛?锛?/span>

鎴戜滑鍏堝涔犱笅涓€涓唴瀹癸紝鐒跺悗鍐嶆潵缁欏ぇ瀹惰В閲婁笂闈㈢殑杩欏彞璇?/p>

鈥淸^]鈥?/span> 锛?strong>鎷彿閲岄潰浠モ€淾鈥濆紑澶达紝鏄瓧绗︾粍鐨勫惁瀹氬舰寮?/span> 锛屾瘮濡傦細[^hate]琛ㄧず锛氬尮閰嶉櫎浜唄銆乤銆乼銆乪浠ュ鐨勫叾浠栧瓧绗︼紝渚濈劧鍙細鍖归厤涓€涓瓧绗?/strong>

涔嬪墠鍒氬垰瀛﹁繃鈥淾鈥濊〃绀轰竴琛岀殑寮€濮嬶紝浣嗘槸鑴卞瓧绗︿綅浜嶽]鍐呯殑璧峰浣嶇疆鍒欒〃绀哄惁瀹氾紝杩欎篃瑙i噴浜?strong>锛?锛?/span> 鐨勫唴瀹?/p>

濡傛灉鑴卞瓧绗︿綅浜庢嫭鍙峰唴鍏朵粬浣嶇疆琛ㄧず浠€涔堝憿锛熼偅瀹冭〃绀哄畠鑷繁锛屾鏃跺苟涓嶅啀鏄竴涓厓瀛楃

鈥?鈥?/span> 锛氬噺鍙凤紝鍙互鍦ㄥ瓧绗︾粍鍐呰〃绀哄尯闂淬€佽寖鍥淬€傛瘮濡傗€淸a-z]鈥濓紝琛ㄧず鍖归厤a鍒皕鐩存帴鐨勪换鎰忎竴涓皬鍐欏瓧姣嶏紝濡傛灉鏄€淸-z]鈥濓紝閭d箞鈥?鈥濆彧琛ㄧず瀹冭嚜宸憋紝娌℃湁浠讳綍鐗规畩鎰忎箟锛屽畠鍦ㄥ瓧绗︾粍澶栦篃娌℃湁浠讳綍鐗规畩鎰忎箟銆?/p>

ps锛氬叧浜庘€淾鈥濄€佲€?鈥濄€佲€?鈥濈殑鍏朵粬鐢ㄦ硶灏嗗湪楂樼骇鍩虹绡囪杩?br>

鈥?鈥?/span> 锛氱偣鍙凤紝鍖归厤涓€涓换鎰忓瓧绗︾殑瀛楃缁勭畝渚垮啓娉曘€?strong>鈥?鈥濆湪瀛楃缁勫唴娌′笉鏄厓瀛楃

ps锛氣€?鈥濅篃涓嶆槸涓囪兘鐨勶紝鏈変簺瀛楃鏃犳硶鍖归厤锛屼箣鍚庝細璇︾粏瑙i噴骞剁粰鍑烘浛浠f柟妗?/span>

鈥渱鈥?/span> 锛氱珫绾匡紝琛ㄧず鎴栬€咃紝杩欎釜寰堝鏄撹蹇嗭紝濡傛灉鎯冲尮閰峢ate鎴栬€卨ike锛岄偅涔堟鍒欎负锛氣€渉ate|like鈥?/p>

娉ㄦ剰锛氬鏋滄兂鍖归厤I hate you鍜孖 like you銆傞偅涔堟鍒欎负锛氣€淚 (hate|like) you鈥濄€傚鏋滃啓鎴愨€淚 hate|like you鈥濓紝閭d箞鍖归厤鐨勭粨鏋滀负鈥淚 hate鈥濇垨鑰呮槸鈥渓ike you鈥濅簡

杩欓噷鍦嗘嫭鍙风殑浣滅敤鏄帶鍒剁珫绾跨殑浣滅敤鑼冨洿锛屸€?)鈥濇湁寰堝浣滅敤锛岀◢鍚庡啀璇?/p>

锛堝浜庝紶缁烴FA鏉ヨ锛岄€夋嫨缁撴瀯鏄寜椤哄簭鐨勶紝骞朵笉鏄尮閰嶄紭鍏堜篃涓嶆槸蹇界暐浼樺厛锛屽叧浜嶯FA璇峰弬鐪?/strong> 娣卞叆鍏ラ棬姝e垯琛ㄨ揪寮忥紙java锛?- 鍖归厤鍘熺悊 - 1 - 寮曟搸鍒嗙被涓庢櫘閫傚師鍒?/a> 锛?/strong>

鈥淺b鈥?/span> 锛氬畠鐨勪綔鐢ㄦ槸鍗曡瘝鍒嗛殧绗︼紝濡傛灉鎴戞兂鍖归厤like锛岄偅涔堟鍒欎负鈥渓ike鈥濓紝娌¢敊锛屼絾鏄細寰楀埌涓€浜涙垜涓嶆兂瑕佺殑缁撴灉锛屾瘮濡俵ikely涔熶細璺戝埌缁撴灉闆嗕腑锛屾垜鍙笉鎯宠杩欎簺鍗曡瘝銆傞偅涔堜慨鏀规鍒欎负锛氣€淺blike\b鈥濓紝杩欏洖灏卞彧鑳藉尮閰峫ike杩欎釜鍗曡瘝浜嗐€?/p>

娉ㄦ剰锛歫ava涓殑鍗曡瘝鍒嗛殧绗︿负鈥淺b鈥濓紝鏈変簺璇█鐨勫崟璇嶅垎闅旂涓?strong>鈥淺<鈥?/span> 鍜?strong>鈥淺>鈥?/span> 銆?/p>

鍗曡瘝杈圭晫鏄粈涔堝憿锛熷叾瀹炴鍒欐病鏈夐偅涔堣仾鏄庯紝瀹冧笉浼氳瘑鍒€淚likeyou鈥濅负鈥淚 like you鈥濓紝瀹冨彧鏄壘鍒版暟瀛楀拰瀛楁瘝鐨勮捣濮嬩綅缃拰缁撴潫浣嶇疆鑰屽凡

鈥淺w鈥?/strong> 锛氬崟璇嶅瓧绗︺€?span >鍦╦ava涓浉褰撲簬鈥淸a-zA-Z0-9_]鈥濄€?/strong>

浣嗘槸java涓殑鈥淺b鈥濆嵈鏀寔Unicode瀛楃銆?/strong>

涓嬮潰鎴戜滑鏉ョ湅鐪嬫鍒欎腑鐨勨€滄暟瀛椻€?- 閲忚瘝

鈥?鈥?/span> 锛氳〃绀?涓嚦1涓?/p>

鈥?鈥?/span> 锛氳〃绀?涓嚦浠绘剰澶氫釜

鈥?鈥?/span> 锛氳〃绀鸿嚦灏戜竴涓?/p>

鈥渰min,max}鈥?/span> 锛氬尯闂撮噺璇嶃€?strong>鈥渰2,5}鈥濓紝琛ㄧず鍖归厤2鍒?娆°€傗€渰2,}鈥濊〃绀鸿嚦灏戜袱娆★紝鈥渰2}鈥濊〃绀哄彧鍖归厤涓ゆ銆?/span> 鈥渰,2}鈥濓紝姝e垯閿欒锛屾棤鎰忎箟

涓句釜渚嬪瓙锛氭濡備笂闈㈢殑鍙嶉潰鏁欑▼鎵€璇达紝濡傛灉鎯冲尮閰嶄竴涓鏁存暟锛岄偅涔堝簲璇ュ浣曟潵鍋?/p>

棣栧厛鎴戜滑闇€瑕佹槑纭細鎴戜笉鎯冲尮閰?123锛屽彧鎯冲尮閰?23杩欐牱鐨勬暟瀛楋紝0涓嶈兘寮€澶达紝绗簩涓姹傚氨鏄櫎浜嗘暟瀛椾笉鑳芥湁鍏朵粬瀛楃浜?/p>

涔嬪墠鎴戜滑瀛﹁繃瀛楃缁勪簡锛屸€淸0-9]鈥濆彲浠ヨ〃绀?鑷?涓换鎰忎竴涓暟瀛楋紝閭d箞鏍规嵁涓婇潰鐨勯噺璇嶏紝鎴戜滑鏀规鍒欎负鈥淸0-9]+鈥濓紝琛ㄧず鑷冲皯鏈変竴涓暟瀛楋紝鑷?澶氭病鏈夐檺鍒躲€備絾鏄?123杩欐牱鐨勬暟瀛椾篃浼氭弧瓒宠姹傘€傞偅涔堟垜浠啀淇敼涓€涓嬶紝棣栧厛绗竴浣嶄笉鑳戒负0锛岄偅涔堣繖涓€浣嶅彲浠ュ啓涓衡€淸1-9]鈥濓紝琛ㄧず鍖归厤1鍒?鐨勪换浣曚竴 涓暟瀛楋紝涔嬪悗鍛紵鍚庨潰鐨勬暟瀛楁湁娌℃湁閮芥棤鎵€璋撲簡锛屾湁锛岄偅灏辨槸澶氫綅鏁帮紝娌℃湁锛岄偅灏辨槸涓€浣嶆暟銆傛墍浠ユ鍒欎负鈥淸1-9][0-9]*鈥濄€?/p>

璐┆涓庢噿鎯?/span>

鎴戜滑鍐嶆潵鐪嬩竴涓噺璇嶇殑渚嬪瓙銆傛瘮濡傛垜鎯冲尮閰嶄竴涓崟璇嶏紝姝e垯鍙互杩欎箞鍐欌€淸a-zA-Z]+鈥濄€?/p>

RegexBuddy姣忔鍖归厤棰滆壊浜ゅ弶锛屽氨鑳界煡閬撴瘡娆¢兘鍖归厤鍒扮殑鏄粈涔堜簡

鎴戜滑鏉ョ湅绗竴娆$殑缁撴灉锛屾槸鈥渢here鈥?/p>

鏈変釜闂灏卞嚭鏉ヤ簡锛氣€淺w+鈥濊〃绀鸿嚦灏戜竴涓€淺w鈥濓紝閭d箞涓轰粈涔堢粨鏋滀笉鏄€渢鈥濄€佲€渉鈥濄€佲€渆鈥濄€佲€渞鈥濄€佲€渆鈥濓紝鑰屾槸鈥渢here鈥濄€?/p>

涓婇潰鐨勯噺璇嶏紝闄や簡鈥渰times}鈥濊繖绉嶆寚瀹氬尮閰嶆鏁扮殑锛屽叾浣欓粯璁ゅ潎涓鸿椽濠尮閰嶃€備篃灏辨槸璇村敖鍙兘澶氱殑鍖归厤銆?/span>

鐩稿鐨勫氨鏈夋儼鎬у尮閰嶏紝閭d箞鎯版€у尮閰嶅浣曚娇鐢紵

涓嬮潰淇敼涓€涓嬩緥瀛愶細鈥淺w*e鈥濊〃绀轰互e缁撳熬鐨勫崟璇嶏紝鐜板湪杩欓噷鐨?杩樻槸璐┆鍖归厤銆?/p>

濡傛灉鎴戞兂鍖归厤鍒板崟璇嶄腑鐨勭涓€涓猠锛岄偅涔堝浣曚慨鏀瑰憿锛?/p>

杩樻槸鏉ョ湅there锛岃繖鍥炩€淺w+鈥濆彧鍖归厤浜嗏€渢h鈥濓紝骞舵病鏈夊尮閰嶅埌鈥渢her鈥濇墠鍋滄銆?/p>

鎯版€у尮閰嶅氨鏄敖鍙兘灏戠殑鍖归厤锛屼娇鐢ㄦ柟娉曞氨鏄湪閲忚瘝鍚庨潰鍔犱笂鈥?鈥?/span>

濡傛灉閲忚瘝鍚庨潰娌℃湁鈥?鈥濈瓑鍏朵粬閲忚瘝锛岄偅涔堝氨鏄粯璁ょ殑璐┆鍖归厤銆?/span>

鈥?鈥濓紝鈥?鈥濓紝鈥?鈥濓細涔熷彨鍖归厤浼樺厛閲忚瘝

鈥??鈥濓紝鈥??鈥濓紝鈥??鈥濓細涔熷彨蹇界暐浼樺厛閲忚瘝

鍏跺疄杩樻湁涓€绉嶉噺璇嶏細

鈥?+鈥濓紝鈥?+鈥濓紝鈥?+鈥濓細鍗犳湁浼樺厛閲忚瘝 銆?/span> 锛堟敮鎸佽繖绉嶉噺璇嶇殑姝e垯寮曟搸寰堝皯锛宩ava鏀寔锛?/p>

杩欒妭涓嶈璁鸿繖绉嶇被鍨嬮噺璇嶏紝涔嬪悗鐨勭珷鑺傝璁?/p>

() 锛氬皢鎷彿閲岄潰鐨勫唴瀹逛綔涓轰竴涓嫭绔嬬殑鍗曞厓锛岀悊瑙d负涓€缁勩€?/p>

鍙嶅悜寮曠敤

鈥淺鈥?鏁板瓧 锛氬ソ澶氳瑷€鑳借浣忊€?)鈥濋噷闈㈠尮閰嶅埌鐨勫唴瀹癸紝姣斿java銆傚鏋滄垜鍙兂浣跨敤鈥?)鈥濆尮閰嶅埌鐨勫唴瀹癸紝閭d箞鍙互浣跨敤鍙嶅悜寮曠敤銆?/p>

姣斿鎴戞兂鎵句袱涓竴鏍风殑鍗曡瘝锛屾€绘湁涓嶅皬蹇冨啓閿欑殑鏃跺€欙紝鍙兘浼氬嚭鐜癶ate hate杩欐牱鐨勬椂鍊欙紝閭d箞姝e垯搴旇濡備綍涔﹀啓鍛紵

鈥?hate) \1鈥?/p>

杩欐牱灏辫兘鍖归厤鍒颁簡

閫氬父鎴戜滑涓嶅彧灞€闄愪簬涓€涓崟璇嶏紝閭d箞鎴戜滑鍙互鍐欎负锛氣€?[a-zA-Z]+) \1鈥?杩欐牱涔熻兘鎵惧埌hate hate褰㈠紡鐨勯敊璇€?/p>

娉ㄦ剰锛氳繖閲?[a-zA-Z]+)琛ㄧず鑷冲皯涓€涓嫳鏂囧瓧姣嶏紝鍚庨潰鐨刓1涓嶈〃绀鸿嚦灏戜竴涓嫳鏂囧瓧姣嶏紝鑰屾槸琛ㄧず璇翠笌()鍖归厤鐨勭粨鏋滀竴鑷达紒 鈥?[a-zA-Z]+) \1鈥濅笉鏄€?[a-zA-Z]+) ([a-zA-Z]+)鈥濈殑绠€鍐?/span>

姣斿锛氱洰鏍囧瓧绗︿覆涓簂ikely like锛屸€?[a-zA-Z]+) 鈥濅細鍖归厤鍒發ikely鍜屼竴涓┖鏍硷紝鈥淺1鈥濅笉浼氬尮閰嶁€?[a-zA-Z]+)鈥濓紝鍥犱负涔嬪墠鎷彿鐨勭粨鏋滀笉鏄痩ike锛屾墍浠ヨ繖娆℃煡鎵惧け璐ワ紝鏃犵粨鏋溿€?/p>

鍙嶅悜寮曠敤涓殑鏁板瓧鐨勭‘瀹?/span>

渚嬪鈥?(\d)(\d))\d鈥濇潵鍖归厤123杩欎釜鏁板瓧銆傞偅涔堚€淺1鈥濈殑缁撴灉鏄亣瑙佺殑绗竴涓嫭鍙凤紝灏辨槸鏈€澶栭潰鐨勶紝鈥淺1鈥濈粨鏋滀负12銆傛寜鐫€椤哄簭鈥淺2鈥濈粨鏋滀负1锛屸€淺3鈥濈粨鏋滀负2

鏈€鍚庡啀璇翠笅鈥?)鈥?/span> 锛?strong>鍙嶅悜寮曠敤 鐨勫紑濮嬪凡缁忚鍑轰簡鎷彿鐨勫彟涓€涓綔鐢紝閭e氨鏄繚瀛樻崟鑾风殑鍐呭锛岃繖绉嶇被鍨嬬殑鎷彿鍙仛鎹曡幏鍨嬫嫭鍙?/strong> 锛岀浉瀵瑰簲鐨勫氨鏈?strong>闈炴崟鑾峰瀷鎷彿鈥??:)鈥?/span>

鈥??:)鈥?/strong> 锛氶潪鎹曡幏鍨嬫嫭鍙枫€傗€??:hate)鈥濅細鍖归厤鍒癶ate杩欎釜瀛楃涓诧紝浣嗘槸濡傛灉浣犱紒鍥句娇鐢ㄥ弽鍚戝紩鐢ㄢ€??:hate) \1鈥濓紝閭d箞灏变細鍑虹幇閿欒銆傝繖鏍风殑鎿嶄綔鏄潪娉曠殑銆?/p>

娉ㄦ剰锛氶潪鎹曡幏鍨嬫嫭鍙蜂笉褰卞搷鎹曡幏璁℃暟 锛岃幏鍙栤€?(?:\d)(\d))鈥濅腑鐨勨€?\d)鈥濇崟鑾风殑鍐呭涓篭2锛屼笉鍐嶆槸\3

濂藉锛?/strong>

1.鎻愰珮鏁堢巼锛屽緢瀹规槗鐞嗚В锛屼笉璁颁綇鎹曡幏鐨勫唴瀹逛篃灏变笉鍗犵敤鍐呭瓨浜?/strong>

2.缁撴瀯娓呮櫚

甯哥敤绌虹櫧瀛楃

鈥淺s鈥?/span> 锛氳〃绀烘墍鏈夌┖鐧藉瓧绗︺€?/p>

鈥淺t鈥?/span> 锛氬埗琛ㄧ銆?/p>

鈥淺n鈥?/span> 锛氭崲琛岀銆?/p>

鈥淺r鈥?/span> 锛氬洖杞︺€?/p>

涓€浜涘叾浠栧父鐢ㄧ殑缂╃暐琛ㄧず

鈥淺S鈥?/span> 锛氶櫎鈥淺s鈥濅箣澶栫殑浠讳綍瀛楃

鈥?/span> \ w鈥?/span> 锛氱瓑鍚屼簬[a-zA-Z0-9_]

鈥?/span> \W 鈥?/span> 锛氶櫎鈥淺w鈥濅箣澶栫殑浠讳綍瀛楃

鈥?/span> \ d鈥?/span> 锛氱瓑鍚屼簬[0-9]

鈥?/span> \ D鈥?/span> 锛氶櫎鈥渄鈥濅箣澶栫殑浠讳綍瀛楃

鏈変簺宸ュ叿涓嶆敮鎸侊紝姣斿EditPlus v3.10 涓殑鏌ユ壘灏变笉鏀寔\d绛夈€?/p>

鐜锛堥浂瀹芥柇瑷€锛?/span>

鐜鍒嗕负椤哄簭鍜岄€嗗簭锛岃偗瀹氬拰鍚﹀畾锛岀粍鍚堜竴涓嬩竴鍏?绉嶃€備笅闈㈠氨鐪嬬湅鐜鍒板簳鏄粈涔?/p>

鈥??=)鈥?/span> 锛氶『搴忚偗瀹氱幆瑙嗭細锛堜粠宸﹁嚦鍙筹級鏌ョ湅鏂囨湰锛屽鏋滆兘澶熷尮閰嶏紝灏辫繑鍥炲尮閰嶆垚鍔熶俊鎭€?/p>

鈥??<=)鈥?/span> 锛氶€嗗簭鑲畾鐜锛氾紙浠庡彸鑷冲乏锛夋煡鐪嬫枃鏈紝濡傛灉鑳藉鍖归厤锛屽氨杩斿洖鍖归厤鎴愬姛淇℃伅銆?/p>

鈥??!)鈥?/span> 锛氶『搴忓惁瀹氱幆瑙嗭細锛堜粠宸﹁嚦鍙筹級鏌ョ湅鏂囨湰锛屽鏋滀笉鑳藉鍖归厤锛屽氨杩斿洖鍖归厤鎴愬姛淇℃伅銆?/p>

鈥??<!)鈥?/span> 锛氶€嗗簭鍚﹀畾鐜锛氾紙浠庡彸鑷冲乏锛夋煡鐪嬫枃鏈紝濡傛灉涓嶈兘澶熷尮閰嶏紝灏辫繑鍥炲尮閰嶆垚鍔熶俊鎭€?/p>

涓嬮潰鐪嬪嚑涓畝鍗曠殑瀹炰緥锛岀劧鍚庡氨寰堝鏄撴槑鐧戒笂闈㈢殑鐏槦璇簡

渚嬶細涓嬮潰鏈変袱鍙ヨ瘽锛屽姞鍏ヤ綘鍙兂鎵惧埌book锛屼笉鎯虫壘鍒癰ooks

there is a book on the desk.
there are some books on the desk.

鏈€绠€鍗曠殑鍔炴硶鏄細鈥渂ook\b鈥濓紝杩欏緢瀹规槗鐞嗚В锛宐ook鍚庨潰璺熺潃鍗曡瘝鍒嗛殧绗︼紝book鍚庨潰濡傛灉鏄痵锛岄偅涔堣偗瀹氳璁や负鏄竴涓崟璇嶏紝鎵€浠ヨ繖鏍蜂笉浼氬尮閰嶅埌books銆傚鏋滅敤鐜锛屽簲璇ュ浣曚功鍐欏憿

姝e垯涓殑book寰堝ソ鐞嗚В锛屼緷娆″尮閰峛銆乷銆乷銆乲锛岀劧鍚庡憿锛孿w鍦ㄤ笂闈㈣杩囩瓑鍚屼簬[a-zA-Z0-9]锛屸€??!\w)鈥濇槸璇达細鎴戣鎵捐繖鏍蜂竴涓綅缃紝杩欎釜浣嶇疆鐨勫悗闈笉鑳芥槸\w銆?/p>

绗竴鍙ヨ瘽涓紝鍦ㄥ尮閰嶄簡book鍚庯紝鍙戠幇绱ц窡鐨勬槸涓€涓┖鏍硷紝鎭╋紝涓嶆槸\w涓殑鍐呭锛屽尮閰嶆垚鍔熴€?/p>

娉ㄦ剰锛氱幆瑙嗕笉浼氬崰鐢ㄥ瓧绗︼紒鐜鏌ユ壘鐨勬槸瀛楃涓庡瓧绗︿箣闂寸殑浣嶇疆銆?/strong>

鐜鎷彿骞舵病鏈夋崟鑾峰瓧绗︾殑鍔熸晥锛屾墍浠ヤ笉鑳戒娇鐢ㄥ弽鍚戝紩鐢ㄣ€?/span>


涓婂浘鐢讳笁瑙掑彿鐨勪綅缃氨鏄繖涓幆瑙嗗尮閰嶇殑浣嶇疆

濡傛灉鎯冲尮閰峛ooks鐨刡ook鎬庝箞鍔烇紝寰堢畝鍗曗€渂ook(?=s)鈥?/p>

涓婇潰婕旂ず浜嗚偗瀹氶『搴忕幆瑙嗗拰鍚﹀畾椤哄簭鐜銆備笅闈㈡紨绀轰簡鐜涓嶅崰鐢ㄥ瓧绗︺€?/p>

姣旇緝瀹规槗鐞嗚В鍚э紝杩欎釜渚嬪瓙娌℃湁浠讳綍瀹為檯鎰忎箟锛屼粎鍋氭紨绀虹敤

涔嬪悗浼氱粰鍑轰竴浜涙湁鎰忎箟鐨勪緥瀛?/p>


2.姝e垯妯″紡涓庡尮閰嶆ā寮?/span>

姝ら儴鍒嗗唴瀹瑰熀鏈潵鑷€婄簿閫氭鍒欒〃杈惧紡銆?v3

1.蹇界暐澶у皬鍐欐ā寮忥細 锛坖ava涓娇鐢≒attern.CASE_INSENSITIVE锛?/p>

2.瀹芥澗鎺掑垪涓庢敞閲婃ā寮忥細 姝ゆā寮忎細蹇界暐瀛楃缁勫閮ㄧ殑鎵€鏈夌┖鐧藉瓧绗?/span> 锛?strong>浣嗘槸鍦╦ava.util.regex涓紝瀛楃缁勪箣澶栫殑鎵€鏈夌┖鐧藉瓧绗﹀苟闈為兘琚拷鐣ワ紝鑰屾槸浣滀负涓€涓€滄棤鎰忎箟瀛楃锛坉o-nothing metacharacter锛夆€?/span> 銆傛鍒欌€淺12 3鈥濊〃鈥?鈥濆湪鈥淺12鈥濅箣鍚庯紝鑰岄潪琛ㄧず鈥淺123鈥濓紙java涓娇鐢≒attern.COMMENTS锛?/p>

ps锛氣€滅┖鐧藉瓧绗︹€濈殑瀹氫箟鍙栧喅浜庢墍閲囩敤鐨勫瓧绗︾紪鐮佺殑瀹氫箟锛屼互鍙婃缂栫爜瀵圭┖鐧藉瓧绗︾殑鏀寔绋嬪害銆?strong>澶у鏁扮▼搴忓彧鑳借瘑鍒獳SCII鐨勭┖鐧藉瓧绗︺€?/span>

3.鐐瑰彿閫氶厤妯″紡锛堝崟琛屾ā寮忥級锛?/span> 锛坉ot-match-all match mode锛?strong>閫氬父鐐瑰彿鏄笉鑳藉尮閰嶆崲琛岀鐨勩€?/span> 浣嗘槸鍦╦ava涓儏鍐电壒娈婏細鍦╯un鐨勬鍒欒〃杈惧紡鍖咃紝鐐瑰彿鑳藉鍖归厤鏈娇鐢ㄦ妯″紡鏃剁偣鍙蜂笉鑳藉尮閰嶇殑鎵€鏈夊崟瀛楃Unicode琛岀粓姝㈢銆?/span> 锛坖ava涓娇鐢≒attern.DOTALL 锛?/p>

绗︼細Unicode琛岀粓姝㈢

瀛楃 鎻忚堪 LF U+000A VT U+000B FF U+000C CR U+000D CR/LF U+000D U+000A NEL U+0085 LS U+2028 PS U+2029 ASCII 鎹㈣绗?/td> ASCII 鍨傜洿鍒惰〃绗?/td> ASCII 杩涚焊绗?/td> ASCII 鍥炶溅 ASCII 鍥炶溅/鎹㈣ Unicode 鎹㈣ Unicode 琛屽垎闅旂 Unicode 娈靛垎闅旂

4.澧炲己鐨勯敋鐐规ā寮忥紙澶氳鏂囨湰妯″紡锛夛細 锛圗nhanced line-anchor match mode锛?strong>姝ゆā寮忓奖鍝嶁€淾鈥濆拰鈥?鈥濈殑鍖归厤銆?/span> 閫氬父鎯呭喌涓嬧€淾鈥濅笉鑳藉尮閰嶅瓧绗︿覆鍐呴儴鐨勬崲琛岀锛岃€屽彧鑳藉尮閰嶇洰鏍囧瓧绗︿覆鐨勮捣濮嬩綅缃€傚湪姝ゅ寮烘ā寮忎笅锛屽畠鑳藉鍖归厤瀛楃涓蹭腑鍐呭祵鐨勬枃鏈鐨勫紑澶翠綅缃€傗€?鈥濅篃鏄繖鏍凤紝姝ゆā寮忎笅鍙互鍖归厤瀛楃涓插唴閮ㄧ殑鎹㈣绗︺€傝繖閲屽彲鑳戒笉鏄緢濂界悊瑙o紝涔嬪悗鐨勫疄渚嬩細浠嬬粛锛屽叾涓繕鍖呮嫭鈥淺A鈥濓紝鈥淺Z鈥?/span> 鍜?strong>鈥淺z鈥?/span> 鐨勬剰涔夛紙java涓娇鐢≒attern.CASE_INSENSITIVE锛?/p>

5.鏂囧瓧鏂囨湰妯″紡锛?/span> 姝ゆā寮忓嚑涔庝笉鑳借瘑鍒换浣曞厓瀛楃 銆傛瘮濡傛妯″紡涓嬫鍒欌€淸a-z]+鈥?鍖归厤鐨勫氨鏄瓧绗︿覆鈥淸a-z]+鈥濊€屽苟涓嶆槸杩炵画鐨勫皬鍐欒嫳鏂囧瓧姣嶏紙java涓娇鐢≒attern.CASE_INSENSITIVE锛?/p>

涓婇潰鐨勫嚑绉嶆ā寮忓鏋滄病鏈夌悊瑙o紝鍙互鐪嬩箣鍚庣殑鏁欑▼銆?/p>

灏嗕細鍦ㄥ熀鏈疄渚嬪拰楂樼骇鍩虹涓璁恒€?/p>


    
[2] 惯用的getResources()系列
    来源: 互联网  发布时间: 2014-02-18
常用的getResources()系列

 

以例子形式说明如何提取资源文件设置view或sting:

private Context ctx;

TextView mText = (TextView)findViewById(R.id.text);
ImageView mImage = (ImageView)findViewById(R.id.image); 
TextView[] mTextViews;
String[] arrays;
String str; 

 

(1)R.dimen.xxx

mText.setTextSize(TypedValue.COMPLEX_UNIT_PX, 
			ctx.getResources().getDimensionPixelSize(R.dimen.xxx));

 

(2)R.color.xxx

mText.setTextColor(ctx.getResources().getColorStateList(R.color.xxx));
mText.setTextColor(ctx.getResources().getColor(R .color.xxx));

 

(3)R.drawable.xxx

mImage.setImageDrawable(ctx.getResources().getDrawable(R.drawable.xxx))

 

(4)R.raw.xxx

InputStream is = ctx.getResources().openRawResource(R.raw.xxx); 

 

(5)R.array.xxx

arrays = getResources().getStringArray(R.array.xxx);

 

(6)R.string.xxx

str = getResources().getString(R.string.xxx)

 

 (7)getIdentifier
用于view的id名称具有相同的部分,如前缀xxx,利用后面的数字进行区别的view

mTextViews = new TextView[LEN]
for (int i = 0; i < mTextViews.length; i++) {
int resId = getResources().getIdentifier("xxx" + i, "id",packageName);
		mTextViews[i] = (TextView) findViewById(resId);}

 

更用Resources应用参看 http://android.toolib.net/reference/android/content/res/Resources.html


    
[3] listView中editview焦点有关问题
    来源: 互联网  发布时间: 2014-02-18
listView中editview焦点问题

http://stackoverflow.com/questions/2679948/focusable-edittext-inside-listview/2680077#2680077


    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
▪Android发送短信功能代码
▪Android根据电话号码获得联系人头像实例代码
▪Android中GPS定位的用法实例
▪Android实现退出时关闭所有Activity的方法
▪Android实现文件的分割和组装
HTML标签参考手册 iis7站长之家
▪Android双击返回键退出程序的实现方法
▪Android实现侦听电池状态显示、电量及充电动...
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
▪Android显式启动与隐式启动Activity的区别介绍
▪Android按钮单击事件的四种常用写法总结
▪Android消息处理机制Looper和Handler详解
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截...
▪Android提高之自定义Menu(TabMenu)实现方法
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3