瀏覽單個文章
Tirpitz
Master Member
 
Tirpitz的大頭照
 

加入日期: Apr 2001
您的住址: Coruscant
文章: 1,637
引用:
Originally posted by harrisonlin
先給你個腦力激盪的機會 - 如果你不急著交作業的話:

先想辦法分割一個字串,以"非 a-z 和 A-Z" 的字元為分界,再個別存起來,例如你舉的例子:

Hi~ what's your name?

切割成:

["Hi", "~", " ", "what", "'", "s", "your", " ", "name", "?"] <-- 這裡我以陣列表示


嗯∼可能真的我想的太複雜了。
因為原來從範例修改使用很多while∼快100行了。
看到token這麼好用就用啦。好像走向不歸路...

我突然發現我雖然把程式碼變短了
但是我不知道該如何去區別一串字母和一串符號...
這才是基本的核心所在吧∼
我不用ascii code了。看到[a-zA-Z0-9]想到regular express。
請各位高手再提示一下吧。(今天已經coding10多小時了,真是廢...不過是個小題目)
     
      
__________________
Un Jedi ne doit connaitre ni la colere, ni la haine, ni l'amour.
Someday I will be the most powerful Jedi ever~!!

Jedi Code
there is no emotion;there is the peace
there is no ignorance;there is the knowledge
there is no passion;there is the serenity
there is no death;there is the Force
舊 2004-05-15, 01:27 AM #11
回應時引用此文章
Tirpitz離線中