載入中 |
載入中 |
以下是PHP去除所有標點符號、特殊符號及空白的程式碼,無論全形或半形標點符號皆會被取代為空字串。
<?php function punctuation_replace($text){ $text=str_replace(array(',','、','。','.','‧',';',':','?','!','…','‥','·','|','–','—','╴','(',')','{','}','〔','〕','【','】','《','》','〈','〉','「','」','『','』','‘','’','“','”','〝','〞','‵','′','#','&','*','※','§','〃','○','●','△','▲','◎','☆','★','◇','◆','□','■','▽','▼','㊣','ˍ','﹉','﹊','﹍','﹎','﹋','﹌','♀','♂','⊕','⊙','↑','↓','←','→','↖','↗','↙','↘','∥','∣','/','\','∕','℅',' ̄','_','+','-','×','÷','±','√','<','>','=','≦','≧','≠','∞','≒','≡','~','∩','∪','⊥','∠','∟','⊿','㏒','㏑','∫','∮','∵','∴','$','¥','〒','¢','£','%','€','℃','℉','°','▁','▂','▃','▄','▅','▆','▇','█','▏','▎','▍','▌','▋','▊','▉','┼','┴','┬','┤','├','▔','─','│','▕','┌','┐','└','┘','╭','╮','╰','╯','═','╞','╪','╡','╔','╦','╗','╠','╬','╣','╚','╩','╝','╒','╤','╕','╘','╧','╛','╓','╥','╖','╟','╫','╢','╙','╨','╜','║','▓','◢','◣','◥','◤','╱','╲','╳','˙','ˉ','ˊ','ˇ','ˋ','゜','゛','・','。','、','・','゙','゚','︰','﹔','﹕','﹐','﹒','❞','❝','﹁','﹂','﹃','﹄',''',' ','"','@','[',']','^','`','「','」','ㅤ','ᅠ','⦅','⦆','¬','¦','₩','○','■','↓','→','↑','←','│','₩','¥','¦','¯','¬','£','¢','⦅','⦆',' ',' ','⟨','⟩','،',')','‒','―','⋯','᠁','ฯ',' ‹','›','«','»','﹏','︴','︳','‐','⧸','⁄','№','¡','¿','º','ª','‰','‱','−','∓','″','‴','¶','‖','•','†','‡','⹋','©','℗','®','℠','™','¤','؋','₳','฿','₿','₵','₡','₢','₫','₯','֏','₠','ƒ','₣','₲','₴','₭','₺','₾','₼','ℳ','₥','₦','₧','₱','₰','﷼','៛','₽','₹','₨','₪','৳','₸','₮','⁂','❧','☞','‽','⸮','◊','⁀','؟','ㆍ','´','ˆ','˝',' ̏ ','¨','ˇ','˘','˚','¸','˛','◌̣',' ̉','˜',' ҃','ː',' ̔',' ̓','⇒','⊃','⇔','↔','∧','∨','ǀ','⊻','∀','∃','≡','־','﹣','﹦','︱','﹨','﹝','﹞','﹙','﹚','﹛','﹜','﹤','﹥','︵','︶','︷','︸','︹','︺','︻','︼','︽','︾','︿','﹀','☎','☏','◐','◑','♡','♥','♣','♧','☻','☺','♠','♤','▪','▫','☜','♫','♬','♦','►','◁','∈','∋','◘','◙','♩','♪','☼','↕','♨','卍','◈','♭','◄','▣','▤','▥','▦','▧','▨','▩','▒','░'),'',preg_replace("/[[:punct:]\s]/",'',trim($text))); return $text; } echo punctuation_replace("你好,我愛你! - 你喜歡我嗎?"); ?>