看板 java 關於我們 聯絡資訊
※ 引述《johnkuokuo@kkcity.com.tw ( )》之銘言: : 我run了程式 結果的確不一樣 : 也看了正則表示式 : 但還是有點有看沒董耶.. : 可不可以再解釋一下...[\t]和[\t]+有什麼不同..謝謝 + 相同於{1,} 表示前面那樣東西可以出現一次以上 其他類似的字還有 * 相同於{0,} ? 相同於{0,1} 回到你的問題 會不一樣的原因是因為 你只用[ \t]去match的話 「每個」空白或Tab都會當成一個分隔 所以在連續的分隔之間切出的就是空字串 如果用[ \t]+去match的話 連續的空白或Tab由於這個式子把它一次抓住了 於是全部一整串空白或Tab就會當成一個分隔 所以就不會有連續的分隔 自然空字串就不見了 -- 'Oh, Harry, dont't you see?' Hermione breathed. 'If she could have done one thing to make absolutely sure that every single person in this school will read your interview, it was banning it!' ---'Harry Potter and the order of the phoenix', P513 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 210.70.172.164