作者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
1F:推 jb0802:感谢~~可是如果像一些有prime的缩写字don't can't tom's 12/20 15:30
2F:→ jb0802:那这样要怎麽解决 12/20 15:31
3F:→ LiloHuang:my @file = $str =~ /([\w']+)/g; 12/20 15:41