Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
因此,如果字符串 $a = "blah bluh bu.du" 我使用以下命令检查字符串中是否包含 du:
if( $a =~ /\.du+/)
现在它确认字符串中有一个“.du”。我怎样才能得到现在保存到新字符串 $b 的单词 budu?我正在使用 perl 抱歉,du 应该像文件扩展名一样
用括号括住要捕获的部分。
if( $a =~ /([a-zA-Z]*?du[a-zA-Z]*?)/){ if ( defined $1 ) { my $word = $1; print "$word\n"; } }