作者LiloHuang (相見不如懷念)
看板Perl
標題Re: [問題] 有關正規表示式
時間Thu Dec 20 13:44:55 2007
: 這樣可以得到串列@file
: 但是如果一串文字: this is a test. just "test".
: ↓ ↓↓ ↓ ↓ ↓
: 若只想取 this is a test just test
: 這樣該怎麼做呢
my $str = 'this is a test. just "test".';
my @file = $str =~ /(\w+)/g;
foreach(@file) {
print $_,$/;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.114.71.40
推 jb0802:感謝~~可是如果像一些有prime的縮寫字don't can't tom's 12/20 15:30
→ jb0802:那這樣要怎麼解決 12/20 15:31
→ LiloHuang:my @file = $str =~ /([\w']+)/g; 12/20 15:41